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 ITemplateItem implementation 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 to implement ITemplateCategory, the compiler tells me that my class is not compatible with CLS.
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 }
Good,
I could just ignore these warnings or disable them by adding the CLSCompliant (false) attribute to my class. But I'm curious why this is happening. Moreover, the compiler does not complain about the output itself.
Does this happen for classes that display interfaces in general, or did I just use a forbidden keyword?
source share