I have the following Interfaces:
public interface ITemplateItem
{
int Id { get; set; }
String Name { get; set; }
String Text { get; set; }
int CategoryId { get; set; }
int Typ { get; set; }
}
public interface ITemplateCategory
{
int Id { get; set; }
String Name { get; set; }
List<ITemplateItem> TemplateItems { get; set; }
void Add(ITemplateItem item);
void Remove(ITemplateItem item);
ITemplateItem CreateTemplateItem();
}
My implementation of the ITemplateItem looks like this:
public class MyTemplateItem : ITemplateItem
{
#region ITemplateItem Member
public int Id { get; set; }
public String Name { get; set; }
public String Text { get; set; }
public int CategoryId { get; set; }
public int Typ { get; set; }
#endregion
}
But for the ITemplateCategory Implementation the compiler tells me that my class is not CLS Compliant.
public class MyTemplateCategory : ITemplateCategory
{
#region ITemplateCategory Member
public int Id { get; set; }
public String Name { get; set; }
// Warning: type of TemplateItems not CLS-Compliant
public List<ITemplateItem> TemplateItems { get; set; }
// Warning: Argument not CLS-Compliant
public void Add(ITemplateItem item)
{
throw new NotImplementedException();
}
// Warning: Argument not CLS-Compliant
public void Remove(ITemplateItem item)
{
throw new NotImplementedException();
}
// Warning: Return type not CLS-Compliant
public ITemplateItem CreateTemplateItem()
{
throw new NotImplementedException();
}
#endregion
}
Ok,
I could just ignore these warnings or turn them off by adding the CLSCompliant(false) attribute to my class. But I am curious why this happens. Expecially because the compiler does not complain about the inferface itself.
Does this happen for classes that expose Interfaces in general or did I just use a forbidden keyword?