本文整理汇总了C#中Mono.CSharp.MemberCore.GetSignatureForError方法的典型用法代码示例。如果您正苦于以下问题:C# MemberCore.GetSignatureForError方法的具体用法?C# MemberCore.GetSignatureForError怎么用?C# MemberCore.GetSignatureForError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.MemberCore
的用法示例。
在下文中一共展示了MemberCore.GetSignatureForError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Resolve
/// <summary>
/// Resolve the constraints - but only resolve things into Expression's, not
/// into actual types.
/// </summary>
public bool Resolve (MemberCore ec, TypeParameter tp, Report Report)
{
if (resolved)
return true;
if (ec == null)
return false;
iface_constraints = new ArrayList (2); // TODO: Too expensive allocation
type_param_constraints = new ArrayList ();
foreach (object obj in constraints) {
if (HasConstructorConstraint) {
Report.Error (401, loc,
"The new() constraint must be the last constraint specified");
return false;
}
if (obj is SpecialConstraint) {
SpecialConstraint sc = (SpecialConstraint) obj;
if (sc == SpecialConstraint.Constructor) {
if (!HasValueTypeConstraint) {
attrs |= GenericParameterAttributes.DefaultConstructorConstraint;
continue;
}
Report.Error (451, loc, "The `new()' constraint " +
"cannot be used with the `struct' constraint");
return false;
}
if ((num_constraints > 0) || HasReferenceTypeConstraint || HasValueTypeConstraint) {
Report.Error (449, loc, "The `class' or `struct' " +
"constraint must be the first constraint specified");
return false;
}
if (sc == SpecialConstraint.ReferenceType)
attrs |= GenericParameterAttributes.ReferenceTypeConstraint;
else
attrs |= GenericParameterAttributes.NotNullableValueTypeConstraint;
continue;
}
int errors = Report.Errors;
FullNamedExpression fn = ((Expression) obj).ResolveAsTypeStep (ec, false);
if (fn == null) {
if (errors != Report.Errors)
return false;
NamespaceEntry.Error_NamespaceNotFound (loc, ((Expression)obj).GetSignatureForError (), Report);
return false;
}
TypeExpr expr;
GenericTypeExpr cexpr = fn as GenericTypeExpr;
if (cexpr != null) {
expr = cexpr.ResolveAsBaseTerminal (ec, false);
} else
expr = ((Expression) obj).ResolveAsTypeTerminal (ec, false);
if ((expr == null) || (expr.Type == null))
return false;
if (!ec.IsAccessibleAs (fn.Type)) {
Report.SymbolRelatedToPreviousError (fn.Type);
Report.Error (703, loc,
"Inconsistent accessibility: constraint type `{0}' is less accessible than `{1}'",
fn.GetSignatureForError (), ec.GetSignatureForError ());
return false;
}
if (TypeManager.IsGenericParameter (expr.Type))
type_param_constraints.Add (expr);
else if (expr.IsInterface)
iface_constraints.Add (expr);
else if (class_constraint != null || iface_constraints.Count != 0) {
Report.Error (406, loc,
"The class type constraint `{0}' must be listed before any other constraints. Consider moving type constraint to the beginning of the constraint list",
expr.GetSignatureForError ());
return false;
} else if (HasReferenceTypeConstraint || HasValueTypeConstraint) {
Report.Error (450, loc, "`{0}': cannot specify both " +
"a constraint class and the `class' " +
"or `struct' constraint", expr.GetSignatureForError ());
return false;
} else
class_constraint = expr;
//
// Checks whether each generic method parameter constraint type
// is valid with respect to T
//
//.........这里部分代码省略.........
示例2: Error_MissingPartialModifier
protected void Error_MissingPartialModifier (MemberCore type)
{
Report.Error (260, type.Location,
"Missing partial modifier on declaration of type `{0}'. Another partial declaration of this type exists",
type.GetSignatureForError ());
}
示例3: AddMember
public void AddMember (MemberCore symbol)
{
if (symbol.MemberName.ExplicitInterface != null) {
if (!(Kind == MemberKind.Class || Kind == MemberKind.Struct)) {
Report.Error (541, symbol.Location,
"`{0}': explicit interface declaration can only be declared in a class or struct",
symbol.GetSignatureForError ());
}
}
AddNameToContainer (symbol, symbol.MemberName.Basename);
members.Add (symbol);
}
示例4: Visit
public override void Visit (MemberCore member)
{
Console.WriteLine ("Unknown member:");
Console.WriteLine (member.GetType () + "-> Member {0}", member.GetSignatureForError ());
}
示例5: AddNameToContainer
public override void AddNameToContainer (MemberCore symbol, string name)
{
if (!(symbol is Constructor) && symbol.MemberName.Name == MemberName.Name) {
if (symbol is TypeParameter) {
Report.Error (694, symbol.Location,
"Type parameter `{0}' has same name as containing type, or method",
symbol.GetSignatureForError ());
return;
}
InterfaceMemberBase imb = symbol as InterfaceMemberBase;
if (imb == null || !imb.IsExplicitImpl) {
Report.SymbolRelatedToPreviousError (this);
Report.Error (542, symbol.Location, "`{0}': member names cannot be the same as their enclosing type",
symbol.GetSignatureForError ());
return;
}
}
base.AddNameToContainer (symbol, name);
}
示例6: AddToContainer
/// <summary>
/// Adds the member to defined_names table. It tests for duplications and enclosing name conflicts
/// </summary>
protected virtual bool AddToContainer (MemberCore symbol, string name)
{
MemberCore mc;
if (!defined_names.TryGetValue (name, out mc)) {
defined_names.Add (name, symbol);
return true;
}
if (((mc.ModFlags | symbol.ModFlags) & Modifiers.COMPILER_GENERATED) != 0)
return true;
if (symbol.EnableOverloadChecks (mc))
return true;
InterfaceMemberBase im = mc as InterfaceMemberBase;
if (im != null && im.IsExplicitImpl)
return true;
Report.SymbolRelatedToPreviousError (mc);
if ((mc.ModFlags & Modifiers.PARTIAL) != 0 && (symbol is ClassOrStruct || symbol is Interface)) {
Error_MissingPartialModifier (symbol);
return false;
}
if (this is ModuleContainer) {
Report.Error (101, symbol.Location,
"The namespace `{0}' already contains a definition for `{1}'",
((DeclSpace)symbol).NamespaceEntry.GetSignatureForError (), symbol.MemberName.Name);
} else if (symbol is TypeParameter) {
Report.Error (692, symbol.Location,
"Duplicate type parameter `{0}'", symbol.GetSignatureForError ());
} else {
Report.Error (102, symbol.Location,
"The type `{0}' already contains a definition for `{1}'",
GetSignatureForError (), symbol.MemberName.Name);
}
return false;
}
示例7: SymbolRelatedToPreviousError
public void SymbolRelatedToPreviousError (MemberCore mc)
{
SymbolRelatedToPreviousError (mc.Location, mc.GetSignatureForError ());
}
示例8: Error_UnexpectedKind
public void Error_UnexpectedKind(Report r, MemberCore mc, string expected, string was, Location loc)
{
string name;
if (mc != null)
name = mc.GetSignatureForError ();
else
name = GetSignatureForError ();
r.Error (118, loc, "`{0}' is a `{1}' but a `{2}' was expected",
name, was, expected);
}
示例9: Error_CyclicDeclaration
public static void Error_CyclicDeclaration (MemberCore mc)
{
Report.Error (110, mc.Location, "The evaluation of the constant value for `{0}' involves a circular definition",
mc.GetSignatureForError ());
}
示例10: GetMethodInfoFromCache
private MethodInfo GetMethodInfoFromCache(MemberCore m, out string signature)
{
signature = "unknown";
TypeSpec containerType = m.Parent.CurrentType;
Dictionary<string, MethodInfo> listOfMethods;
if (methodsByTypes.TryGetValue(containerType, out listOfMethods) == false) {
return null;
}
signature = GetSignature(m);
MethodInfo methodInfo = listOfMethods[signature];
if (methodInfo == null) {
if (verbose) {
Console.WriteLine("[Auto-sealing] Error when looking for method {0}.", m.GetSignatureForError());
}
} else if (methodInfo.Member != m) {
if (verbose) {
Console.WriteLine("[Auto-sealing] Error when matching method {0}.", m.GetSignatureForError());
}
}
return methodInfo;
}
示例11: FinalizeVirtualState
private void FinalizeVirtualState(MemberCore m, bool updateModFlags)
{
string signature;
MethodInfo methodInfo = GetMethodInfoFromCache(m, out signature);
if (methodInfo != null) {
switch (methodInfo.Type) {
case VirtualType.Unknown:
if (verbose) {
Console.WriteLine("[Auto-sealing] Error with method {0}. Still has an unknown virtual type.", methodInfo.Member.GetSignatureForError());
}
break;
case VirtualType.FirstAndOnlyVirtual:
// This the first and only virtual, it is as if the method was not virtual at all
if (updateModFlags) {
m.ModFlags &= ~Modifiers.VIRTUAL;
methodInfo.Member.ModFlags &= ~Modifiers.VIRTUAL;
}
methodInfo.Type = VirtualType.NotVirtual;
if (verbose) {
Console.WriteLine("[Auto-sealing] Remove virtual on {0}", m.GetSignatureForError());
}
break;
case VirtualType.OverrideVirtual:
// Set the override flag in case it was not set
if (updateModFlags) {
m.ModFlags &= ~Modifiers.VIRTUAL;
m.ModFlags |= Modifiers.OVERRIDE;
}
if (verbose) {
Console.WriteLine("[Auto-sealing] Make override on {0}", m.GetSignatureForError());
}
break;
case VirtualType.FirstVirtual:
if ((m.Parent.ModFlags & Modifiers.SEALED) != 0) {
// This case can happen if we could not track correctly the method earlier
if (verbose) {
Console.WriteLine("[Auto-sealing] Remove virtual (due to sealed class) on {0}", m.GetSignatureForError());
}
m.ModFlags &= ~Modifiers.VIRTUAL;
}
break;
}
}
}
示例12: ResolveAsConstant
public Constant ResolveAsConstant (EmitContext ec, MemberCore mc)
{
Expression e = Resolve (ec);
if (e == null)
return null;
Constant c = e as Constant;
if (c != null)
return c;
if (type != null && TypeManager.IsReferenceType (type))
Const.Error_ConstantCanBeInitializedWithNullOnly (type, loc, mc.GetSignatureForError ());
else
Const.Error_ExpressionMustBeConstant (loc, mc.GetSignatureForError ());
return null;
}
示例13: GetDocCommentNode
XmlNode GetDocCommentNode (MemberCore mc, string name)
{
// FIXME: It could be even optimizable as not
// to use XmlDocument. But anyways the nodes
// are not kept in memory.
XmlDocument doc = XmlDocumentation;
try {
XmlElement el = doc.CreateElement ("member");
el.SetAttribute ("name", name);
string normalized = mc.DocComment;
el.InnerXml = normalized;
string [] split = normalized.Split ('\n');
el.InnerXml = line_head + String.Join (line_head, split);
return el;
} catch (Exception ex) {
Report.Warning (1570, 1, mc.Location, "XML documentation comment on `{0}' is not well-formed XML markup ({1})",
mc.GetSignatureForError (), ex.Message);
return doc.CreateComment (String.Format ("FIXME: Invalid documentation markup was found for member {0}", name));
}
}
示例14: FindDocumentedMemberNoNest
private static MemberInfo FindDocumentedMemberNoNest (
MemberCore mc, Type type, string member_name,
Type [] param_list, DeclSpace ds, out int warning_type,
string cref, bool warn419, string name_for_error, Report Report)
{
warning_type = 0;
MemberInfo [] mis;
if (param_list == null) {
// search for fields/events etc.
mis = TypeManager.MemberLookup (type, null,
type, MemberTypes.All,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
member_name, null);
mis = FilterOverridenMembersOut (mis);
if (mis == null || mis.Length == 0)
return null;
if (warn419 && IsAmbiguous (mis))
Report419 (mc, name_for_error, mis, Report);
return mis [0];
}
MethodSignature msig = new MethodSignature (member_name, null, param_list);
mis = FindMethodBase (type,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
msig);
if (warn419 && mis.Length > 0) {
if (IsAmbiguous (mis))
Report419 (mc, name_for_error, mis, Report);
return mis [0];
}
// search for operators (whose parameters exactly
// matches with the list) and possibly report CS1581.
string oper = null;
string return_type_name = null;
if (member_name.StartsWith ("implicit operator ")) {
Operator.GetMetadataName (Operator.OpType.Implicit);
return_type_name = member_name.Substring (18).Trim (wsChars);
}
else if (member_name.StartsWith ("explicit operator ")) {
oper = Operator.GetMetadataName (Operator.OpType.Explicit);
return_type_name = member_name.Substring (18).Trim (wsChars);
}
else if (member_name.StartsWith ("operator ")) {
oper = member_name.Substring (9).Trim (wsChars);
switch (oper) {
// either unary or binary
case "+":
oper = param_list.Length == 2 ?
Operator.GetMetadataName (Operator.OpType.Addition) :
Operator.GetMetadataName (Operator.OpType.UnaryPlus);
break;
case "-":
oper = param_list.Length == 2 ?
Operator.GetMetadataName (Operator.OpType.Subtraction) :
Operator.GetMetadataName (Operator.OpType.UnaryNegation);
break;
default:
oper = Operator.GetMetadataName (oper);
if (oper != null)
break;
warning_type = 1584;
Report.Warning (1020, 1, mc.Location, "Overloadable {0} operator is expected", param_list.Length == 2 ? "binary" : "unary");
Report.Warning (1584, 1, mc.Location, "XML comment on `{0}' has syntactically incorrect cref attribute `{1}'",
mc.GetSignatureForError (), cref);
return null;
}
}
// here we still don't consider return type (to
// detect CS1581 or CS1002+CS1584).
msig = new MethodSignature (oper, null, param_list);
mis = FindMethodBase (type,
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance,
msig);
if (mis.Length == 0)
return null; // CS1574
MemberInfo mi = mis [0];
Type expected = mi is MethodInfo ?
((MethodInfo) mi).ReturnType :
mi is PropertyInfo ?
((PropertyInfo) mi).PropertyType :
null;
if (return_type_name != null) {
Type returnType = FindDocumentedType (mc, return_type_name, ds, cref, Report);
if (returnType == null || returnType != expected) {
warning_type = 1581;
Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute `{0}'", cref);
return null;
}
}
return mis [0];
}
示例15: CheckParametersComments
//
// Raised (and passed an XmlElement that contains the comment)
// when GenerateDocComment is writing documentation expectedly.
//
// FIXME: with a few effort, it could be done with XmlReader,
// that means removal of DOM use.
//
void CheckParametersComments (MemberCore member, IParametersMember paramMember, XmlElement el)
{
HashSet<string> found_tags = null;
foreach (XmlElement pelem in el.SelectNodes ("param")) {
string xname = pelem.GetAttribute ("name");
if (xname.Length == 0)
continue; // really? but MS looks doing so
if (found_tags == null) {
found_tags = new HashSet<string> ();
}
if (xname != "" && paramMember.Parameters.GetParameterIndexByName (xname) < 0) {
Report.Warning (1572, 2, member.Location,
"XML comment on `{0}' has a param tag for `{1}', but there is no parameter by that name",
member.GetSignatureForError (), xname);
continue;
}
if (found_tags.Contains (xname)) {
Report.Warning (1571, 2, member.Location,
"XML comment on `{0}' has a duplicate param tag for `{1}'",
member.GetSignatureForError (), xname);
continue;
}
found_tags.Add (xname);
}
if (found_tags != null) {
foreach (Parameter p in paramMember.Parameters.FixedParameters) {
if (!found_tags.Contains (p.Name) && !(p is ArglistParameter))
Report.Warning (1573, 4, member.Location,
"Parameter `{0}' has no matching param tag in the XML comment for `{1}'",
p.Name, member.GetSignatureForError ());
}
}
}