//
// Copyright 2001 Ximian, Inc (http://www.ximian.com)
// Copyright 2004-2008 Novell, Inc
+// Copyright 2011 Xamarin Inc
//
//
using System;
using System.Collections.Generic;
+using System.Diagnostics;
#if NET_2_1
using XmlElement = System.Object;
//
// Better name would be DottenName
//
+ [DebuggerDisplay ("{GetSignatureForError()}")]
public class MemberName {
public readonly string Name;
public TypeArguments TypeArguments;
return true;
}
- public virtual IList<MethodSpec> LookupExtensionMethod (TypeSpec extensionType, string name, int arity, ref NamespaceEntry scope)
+ public virtual ExtensionMethodCandidates LookupExtensionMethod (TypeSpec extensionType, string name, int arity)
{
- return Parent.LookupExtensionMethod (extensionType, name, arity, ref scope);
+ return Parent.LookupExtensionMethod (extensionType, name, arity);
}
public virtual FullNamedExpression LookupNamespaceAlias (string name)
return Parent.NamespaceEntry.LookupNamespaceAlias (name);
}
- public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, Location loc, bool ignore_cs0104)
+ public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
- return Parent.LookupNamespaceOrType (name, arity, loc, ignore_cs0104);
+ return Parent.LookupNamespaceOrType (name, arity, mode, loc);
}
/// <summary>
return true;
}
- //
- // Raised (and passed an XmlElement that contains the comment)
- // when GenerateDocComment is writing documentation expectedly.
- //
- internal virtual void OnGenerateDocComment (XmlElement intermediateNode)
- {
- }
-
//
// Returns a string that represents the signature for this
// member which should be used in XML documentation.
//
- public virtual string GetDocCommentName (DeclSpace ds)
- {
- if (ds == null || this is DeclSpace)
- return DocCommentHeader + Name;
- else
- return String.Concat (DocCommentHeader, ds.Name, ".", Name);
- }
+ public abstract string GetSignatureForDocumentation ();
//
// Generates xml doc comments (if any), and if required,
// handle warning report.
//
- internal virtual void GenerateDocComment (DeclSpace ds)
+ internal virtual void GenerateDocComment (DocumentationBuilder builder)
{
+ if (DocComment == null) {
+ if (IsExposedFromAssembly ()) {
+ Constructor c = this as Constructor;
+ if (c == null || !c.IsDefault ())
+ Report.Warning (1591, 4, Location,
+ "Missing XML comment for publicly visible type or member `{0}'", GetSignatureForError ());
+ }
+
+ return;
+ }
+
try {
- DocUtil.GenerateDocComment (this, ds, Report);
+ builder.GenerateDocumentationForMember (this);
} catch (Exception e) {
throw new InternalErrorException (this, e);
}
get { return null; }
}
- public virtual bool HasUnresolvedConstraints {
- get { return false; }
- }
-
public bool IsObsolete {
get {
if (GetAttributeObsolete () != null)
MissingDependency_Undetected = 1 << 4,
MissingDependency = 1 << 5,
HasDynamicElement = 1 << 6,
+ ConstraintsChecked = 1 << 7,
IsAccessor = 1 << 9, // Method is an accessor
IsGeneric = 1 << 10, // Member contains type arguments
PendingMemberCacheMembers = 1 << 14,
PendingBaseTypeInflate = 1 << 15,
InterfacesExpanded = 1 << 16,
- IsNotRealProperty = 1 << 17,
+ IsNotCSharpCompatible = 1 << 17,
SpecialRuntimeType = 1 << 18,
InflatedExpressionType = 1 << 19,
InflatedNullableType = 1 << 20,
+ GenericIterateInterface = 1 << 21,
+ GenericTask = 1 << 22
}
protected Modifiers modifiers;
}
}
+ //
+ // Returns true for imported members which are not compatible with C# language
+ //
+ public bool IsNotCSharpCompatible {
+ get {
+ return (state & StateFlags.IsNotCSharpCompatible) != 0;
+ }
+ set {
+ state = value ? state | StateFlags.IsNotCSharpCompatible : state & ~StateFlags.IsNotCSharpCompatible;
+ }
+ }
+
public bool IsPrivate {
get { return (modifiers & Modifiers.PRIVATE) != 0; }
}
return cls == false;
}
+ public virtual string GetSignatureForDocumentation ()
+ {
+ return DeclaringType.GetSignatureForDocumentation () + "." + Name;
+ }
+
public virtual string GetSignatureForError ()
{
var bf = MemberDefinition as Property.BackingField;
}
//
- // Is this member accessible from invocationType
+ // Is this member accessible from invocation context
//
- public bool IsAccessible (TypeSpec invocationType)
+ public bool IsAccessible (IMemberContext ctx)
{
var ma = Modifiers & Modifiers.AccessibilityMask;
if (ma == Modifiers.PUBLIC)
return true;
var parentType = /* this as TypeSpec ?? */ DeclaringType;
+ var ctype = ctx.CurrentType;
- // It's null for module context
- if (invocationType == null)
- invocationType = InternalType.FakeInternalType;
-
- //
- // If only accessible to the current class or children
- //
- if (ma == Modifiers.PRIVATE)
- return invocationType.MemberDefinition == parentType.MemberDefinition ||
- TypeManager.IsNestedChildOf (invocationType, parentType.MemberDefinition);
+ if (ma == Modifiers.PRIVATE) {
+ if (ctype == null)
+ return false;
+ //
+ // It's only accessible to the current class or children
+ //
+ if (parentType.MemberDefinition == ctype.MemberDefinition)
+ return true;
+
+ return TypeManager.IsNestedChildOf (ctype, parentType.MemberDefinition);
+ }
if ((ma & Modifiers.INTERNAL) != 0) {
bool b;
- var assembly = invocationType == InternalType.FakeInternalType ?
- RootContext.ToplevelTypes.DeclaringAssembly :
- invocationType.MemberDefinition.DeclaringAssembly;
+ var assembly = ctype == null ? ctx.Module.DeclaringAssembly : ctype.MemberDefinition.DeclaringAssembly;
if (parentType == null) {
b = ((ITypeDefinition) MemberDefinition).IsInternalAsPublic (assembly);
return b;
}
- // PROTECTED
- if (!TypeManager.IsNestedFamilyAccessible (invocationType, parentType))
- return false;
+ //
+ // Checks whether `ctype' is a subclass or nested child of `parentType'.
+ //
+ while (ctype != null) {
+ if (TypeManager.IsFamilyAccessible (ctype, parentType))
+ return true;
- return true;
+ // Handle nested types.
+ ctype = ctype.DeclaringType; // TODO: Untested ???
+ }
+
+ return false;
}
//
return (state & StateFlags.CLSCompliant) != 0;
}
- public bool IsConditionallyExcluded (Location loc)
+ public bool IsConditionallyExcluded (CompilerContext ctx, Location loc)
{
if ((Kind & (MemberKind.Class | MemberKind.Method)) == 0)
return false;
return false;
foreach (var condition in conditions) {
- if (loc.CompilationUnit.IsConditionalDefined (condition))
+ if (loc.CompilationUnit.IsConditionalDefined (ctx, condition))
return false;
}
// This is the namespace in which this typecontainer
// was declared. We use this to resolve names.
//
- public NamespaceEntry NamespaceEntry;
+ public NamespaceContainer NamespaceEntry;
public readonly string Basename;
}
}
- static string[] attribute_targets = new string [] { "type" };
+ static readonly string[] attribute_targets = new string [] { "type" };
- public DeclSpace (NamespaceEntry ns, DeclSpace parent, MemberName name,
+ public DeclSpace (NamespaceContainer ns, DeclSpace parent, MemberName name,
Attributes attrs)
: base (parent, name, attrs)
{
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) {
+ 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);
+ "The type `{0}' already contains a definition for `{1}'",
+ GetSignatureForError (), name);
}
return false;
type.GetSignatureForError ());
}
+ public override string GetSignatureForDocumentation ()
+ {
+ return Name;
+ }
+
public override string GetSignatureForError ()
{
return MemberName.GetSignatureForError ();