n.WriteTo (RootContext.Documentation.XmlCommentOutput);
}
- else if (mc.IsExposedFromAssembly (ds) &&
- // There are no warnings when the container also
- // misses documentations.
- (ds == null || ds.DocComment != null))
- {
- Report.Warning (1591, 4, mc.Location,
- "Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
+ else if (mc.IsExposedFromAssembly (ds)) {
+ Constructor c = mc as Constructor;
+ if (c == null || !c.IsDefault ())
+ Report.Warning (1591, 4, mc.Location,
+ "Missing XML comment for publicly visible type or member '{0}'", mc.GetSignatureForError ());
}
}
// returns a full runtime type name from a name which might
// be C# specific type name.
//
- private static Type FindDocumentedType (MemberCore mc,
- string name, DeclSpace ds, bool allowAlias)
+ private static Type FindDocumentedType (MemberCore mc, string name, DeclSpace ds, string cref)
{
bool isArray = false;
string identifier = name;
isArray = true;
}
}
- Type t = FindDocumentedTypeNonArray (mc, identifier,
- ds, allowAlias);
+ Type t = FindDocumentedTypeNonArray (mc, identifier, ds, cref);
if (t != null && isArray)
t = Array.CreateInstance (t, 0).GetType ();
return t;
}
- private static Type FindDocumentedTypeNonArray (MemberCore mc,
- string identifier, DeclSpace ds, bool allowAlias)
+ private static Type FindDocumentedTypeNonArray (MemberCore mc,
+ string identifier, DeclSpace ds, string cref)
{
switch (identifier) {
case "int":
case "void":
return typeof (void);
}
- if (allowAlias) {
- IAlias alias = ds.LookupAlias (identifier);
- if (alias != null)
- identifier = alias.Name;
- }
- Type t = ds.FindType (mc.Location, identifier);
- if (t == null)
- t = TypeManager.LookupTypeDirect (identifier);
- return t;
+ FullNamedExpression e = ds.LookupType (identifier, mc.Location, false);
+ if (e != null) {
+ if (!(e is TypeExpr))
+ return null;
+ return ((TypeExpr) e).ResolveType (ds.EmitContext);
+ }
+ int index = identifier.LastIndexOf ('.');
+ if (index < 0)
+ return null;
+ int warn;
+ Type parent = FindDocumentedType (mc, identifier.Substring (0, index), ds, cref);
+ if (parent == null)
+ return null;
+ return FindDocumentedMember (mc, parent,
+ identifier.Substring (index + 1),
+ emptyParamList,
+ ds, out warn, cref) as Type;
}
//
((PropertyInfo) mi).PropertyType :
null;
if (returnTypeName != null) {
- Type returnType = FindDocumentedType (mc, returnTypeName, ds, true);
+ Type returnType = FindDocumentedType (mc, returnTypeName, ds, cref);
if (returnType == null || returnType != expected) {
warningType = 1581;
Report.Warning (1581, 1, mc.Location, "Invalid return type in XML comment cref attribute '{0}'", cref);
name = signature;
parameters = String.Empty;
}
+ Normalize (mc, ref name);
string identifier = name;
// Check if identifier is valid.
// This check is not necessary to mark as error, but
// csc specially reports CS1584 for wrong identifiers.
- foreach (string nameElem in identifier.Split ('.')) {
+ string [] nameElems = identifier.Split ('.');
+ for (int i = 0; i < nameElems.Length; i++) {
+ string nameElem = nameElems [i];
+ if (nameElem.EndsWith ("[]"))
+ nameElem = nameElem.Substring (
+ nameElem.Length - 2);
+ if (i > 0)
+ Normalize (mc, ref nameElem);
if (!Tokenizer.IsValidIdentifier (nameElem)
&& nameElem.IndexOf ("operator") < 0) {
- if (nameElem.EndsWith ("[]") &&
- Tokenizer.IsValidIdentifier (
- nameElem.Substring (
- 0, nameElem.Length - 2)))
- continue;
-
Report.Warning (1584, 1, mc.Location, "XML comment on '{0}' has syntactically incorrect attribute '{1}'", mc.GetSignatureForError (), cref);
xref.SetAttribute ("cref", "!:" + signature);
return;
ArrayList plist = new ArrayList ();
for (int i = 0; i < paramList.Length; i++) {
string paramTypeName = paramList [i].Trim (wsChars);
- Type paramType = FindDocumentedType (mc, paramTypeName, ds, true);
+ Normalize (mc, ref paramTypeName);
+ Type paramType = FindDocumentedType (mc, paramTypeName, ds, cref);
if (paramType == null) {
Report.Warning (1580, 1, mc.Location, "Invalid type for parameter '{0}' in XML comment cref attribute '{1}'", i + 1, cref);
return;
parameters = sb.ToString ();
}
- Type type = FindDocumentedType (mc, name, ds, true);
+ Type type = FindDocumentedType (mc, name, ds, cref);
if (type != null) {
xref.SetAttribute ("cref", "T:" + type.FullName.Replace ("+", "."));
return; // a type
if (period > 0) {
string typeName = name.Substring (0, period);
string memberName = name.Substring (period + 1);
- type = FindDocumentedType (mc, typeName, ds, false);
+ Normalize (mc, ref memberName);
+ type = FindDocumentedType (mc, typeName, ds, cref);
int warnResult;
if (type != null) {
MemberInfo mi = FindDocumentedMember (mc, type, memberName, parameterTypes, ds, out warnResult, cref);
GenerateDocComment (mc, e);
}
}
+
+ private static void Normalize (MemberCore mc, ref string name)
+ {
+ if (name.Length > 0 && name [0] == '@')
+ name = name.Substring (1);
+ else if (Tokenizer.IsKeyword (name) && !IsTypeName (name))
+ Report.Warning (1041, 1, mc.Location, String.Format ("Identifier expected, '{0}' is a keyword", name));
+ }
+
+ private static bool IsTypeName (string name)
+ {
+ switch (name) {
+ case "bool":
+ case "byte":
+ case "char":
+ case "decimal":
+ case "double":
+ case "float":
+ case "int":
+ case "long":
+ case "object":
+ case "sbyte":
+ case "short":
+ case "string":
+ case "uint":
+ case "ulong":
+ case "ushort":
+ case "void":
+ return true;
+ }
+ return false;
+ }
}
//