// Licensed under the terms of the GNU GPL
//
// (C) 2001, 2002, 2003 Ximian, Inc (http://www.ximian.com)
+// (C) 2004 Novell, Inc
//
//
// 2002-10-11 Miguel de Icaza <miguel@ximian.com>
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
+using System.Xml;
using Mono.CompilerServices.SymbolWriter;
return null;
}
- if (!parent.AsAccessible (this, ModFlags))
- Report.Error (60, Location,
- "Inconsistent accessibility: base class `" +
- parent.Name + "' is less accessible than class `" +
- Name + "'");
+ if (!parent.AsAccessible (this, ModFlags)) {
+ Report.SymbolRelatedToPreviousError (parent.Type);
+ Report.Error (60, Location, "Inconsistent accessibility: base class '{0}' is less accessible than class '{1}'",
+ TypeManager.CSharpName (parent.Type), GetSignatureForError ());
+ }
}
if (parent != null)
}
if (iface.IsClass) {
- if (parent != null){
- Report.Error (527, Location,
- "In Class `{0}', `{1}' is not " +
- "an interface", Name, iface.Name);
- error = true;
- return null;
- }
+ Report.Error (1722, Location,
+ "In Class `{0}', `{1}' is not " +
+ "an interface, a base class must be listed first", Name, iface.Name);
+ error = true;
+ return null;
}
for (int x = 0; x < i; x++) {
}
}
+ public Constructor DefaultStaticConstructor {
+ get { return default_static_constructor; }
+ }
+
protected override bool VerifyClsCompliance (DeclSpace ds)
{
if (!base.VerifyClsCompliance (ds))
return FindMembers (mt, new_bf, null, null);
}
+ //
+ // Generates xml doc comments (if any), and if required,
+ // handle warning report.
+ //
+ internal override void GenerateDocComment (DeclSpace ds)
+ {
+ DocUtil.GenerateTypeDocComment (this, ds);
+ }
+
+ public override string DocCommentHeader {
+ get { return "T:"; }
+ }
+
public virtual MemberCache ParentCache {
get {
return parent_cache;
public readonly TypeAttributes DefaultTypeAttributes;
static PartialContainer Create (NamespaceEntry ns, TypeContainer parent,
- MemberName name, int mod_flags, Kind kind,
+ MemberName member_name, int mod_flags, Kind kind,
Location loc)
{
PartialContainer pc;
- string full_name = name.GetName (true);
+ string full_name = member_name.GetName (true);
DeclSpace ds = (DeclSpace) RootContext.Tree.Decls [full_name];
if (ds != null) {
pc = ds as PartialContainer;
260, ds.Location, "Missing partial modifier " +
"on declaration of type `{0}'; another " +
"partial implementation of this type exists",
- name);
+ member_name.GetPartialName());
Report.LocationOfPreviousError (loc);
return null;
Report.Error (
261, loc, "Partial declarations of `{0}' " +
"must be all classes, all structs or " +
- "all interfaces", name);
+ "all interfaces", member_name.GetPartialName ());
return null;
}
Report.Error (
262, loc, "Partial declarations of `{0}' " +
"have conflicting accessibility modifiers",
- name);
+ member_name.GetPartialName ());
return null;
}
return pc;
}
- pc = new PartialContainer (ns, parent, name, mod_flags, kind, loc);
+ pc = new PartialContainer (ns, parent, member_name, mod_flags, kind, loc);
RootContext.Tree.RecordDecl (full_name, pc);
parent.AddType (pc);
pc.Register ();
return false;
}
+ //
+ // Returns a string that represents the signature for this
+ // member which should be used in XML documentation.
+ //
+ public override string GetDocCommentName (DeclSpace ds)
+ {
+ return DocUtil.GetMethodDocCommentName (this, ds);
+ }
+
+ //
+ // 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.
+ //
+ internal override void OnGenerateDocComment (DeclSpace ds, XmlElement el)
+ {
+ DocUtil.OnMethodGenerateDocComment (this, ds, el);
+ }
+
+ //
+ // Represents header string for documentation comment.
+ //
+ public override string DocCommentHeader {
+ get { return "M:"; }
+ }
+
protected override void VerifyObsoleteAttribute()
{
base.VerifyObsoleteAttribute ();
"Inconsistent accessibility: indexer return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than indexer `" + Name + "'");
- else if (this is Method) {
- if (((Method) this).IsOperator)
+ else if (this is MethodCore) {
+ if (this is Operator)
Report.Error (56, Location,
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"Inconsistent accessibility: return type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than method `" + Name + "'");
- } else
+ } else {
Report.Error (52, Location,
"Inconsistent accessibility: field type `" +
TypeManager.CSharpName (MemberType) + "' is less " +
"accessible than field `" + Name + "'");
+ }
return false;
}
InterfaceType = iface_texpr.Type;
- if (InterfaceType.IsClass) {
- Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", ExplicitInterfaceName);
+ if (!InterfaceType.IsInterface) {
+ Report.Error (538, Location, "'{0}' in explicit interface declaration is not an interface", TypeManager.CSharpName (InterfaceType));
return false;
}
[Flags]
public enum Status : byte {
ASSIGNED = 1,
- USED = 2
+ USED = 2,
+ HAS_OFFSET = 4 // Used by FieldMember.
}
static string[] attribute_targets = new string [] { "field" };
public abstract class FieldMember: FieldBase
{
- bool has_field_offset = false;
+
protected FieldMember (TypeContainer parent, Expression type, int mod,
int allowed_mod, MemberName name, object init, Attributes attrs, Location loc)
{
if (a.Type == TypeManager.field_offset_attribute_type)
{
- has_field_offset = true;
+ status |= Status.HAS_OFFSET;
if (!Parent.HasExplicitLayout) {
Report.Error (636, Location, "The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)");
public override void Emit ()
{
- if (Parent.HasExplicitLayout && !has_field_offset && (ModFlags & Modifiers.STATIC) == 0) {
+ if (Parent.HasExplicitLayout && ((status & Status.HAS_OFFSET) == 0) && (ModFlags & Modifiers.STATIC) == 0) {
Report.Error (625, Location, "'{0}': Instance field types marked with StructLayout(LayoutKind.Explicit) must have a FieldOffset attribute.", GetSignatureForError ());
}
base.Emit ();
}
+
+ //
+ // Represents header string for documentation comment.
+ //
+ public override string DocCommentHeader {
+ get { return "F:"; }
+ }
}
//
{
if (a.Type == TypeManager.cls_compliant_attribute_type || a.Type == TypeManager.obsolete_attribute_type ||
a.Type == TypeManager.conditional_attribute_type) {
- Report.Error (1667, a.Location, "'{0}' is not valid on property or event accessors. It is valid on '{1}' declarations only", TypeManager.CSharpName (a.Type), a.GetValidTargets ());
+ Report.Error (1667, a.Location, "'{0}' is not valid on property or event accessors. It is valid on {1} declarations only", TypeManager.CSharpName (a.Type), a.GetValidTargets ());
return;
}
public override bool Define()
{
- return false;
+ throw new NotSupportedException ();
}
public virtual void Emit (TypeContainer container)
}
}
+ //
+ // Represents header string for documentation comment.
+ //
+ public override string DocCommentHeader {
+ get { throw new InvalidOperationException ("Unexpected attempt to get doc comment from " + this.GetType () + "."); }
+ }
+
protected override void VerifyObsoleteAttribute()
{
}
return attribute_targets;
}
}
+
+ //
+ // Represents header string for documentation comment.
+ //
+ public override string DocCommentHeader {
+ get { return "P:"; }
+ }
}
public class Property : PropertyBase, IIteratorContainer {
{
Add = new AddDelegateMethod (this, add);
Remove = new RemoveDelegateMethod (this, remove);
+
+ // For this event syntax we don't report error CS0067
+ // because it is hard to do it.
+ SetAssigned ();
}
public override string[] ValidAttributeTargets {
public class EventField: Event {
static string[] attribute_targets = new string [] { "event", "field", "method" };
+ static string[] attribute_targets_interface = new string[] { "event", "method" };
public EventField (TypeContainer parent, Expression type, int mod_flags,
bool is_iface, MemberName name, Object init,
}
if (a.Target == AttributeTargets.Method) {
- AddBuilder.SetCustomAttribute (cb);
- RemoveBuilder.SetCustomAttribute (cb);
+ Add.ApplyAttributeBuilder (a, cb);
+ Remove.ApplyAttributeBuilder (a, cb);
return;
}
public override string[] ValidAttributeTargets {
get {
- return attribute_targets;
+ return IsInterface ? attribute_targets_interface : attribute_targets;
}
}
}
return TypeManager.GetFullNameSignature (EventBuilder);
}
+
+ //
+ // Represents header string for documentation comment.
+ //
+ public override string DocCommentHeader {
+ get { return "E:"; }
+ }
}
return false;
if (OptAttributes != null) {
- Attribute indexer_attr = OptAttributes.GetIndexerNameAttribute (ec);
+ Attribute indexer_attr = OptAttributes.Search (TypeManager.indexer_name_type, ec);
if (indexer_attr != null) {
+ // Remove the attribute from the list because it is not emitted
+ OptAttributes.Attrs.Remove (indexer_attr);
+
ShortName = indexer_attr.GetIndexerAttributeValue (ec);
if (IsExplicitImpl) {