To naprawdę mnie przeraża. Próbowałem usunąć tylko do odczytu, zmieniając nazwy. Co ja tu robię źle?Dlaczego moja klasa nie jest zgodna z CLS?
public abstract class CatalogBase<T> where T : class
{
protected readonly String DataPath;
protected readonly XmlSerializer Serializer;
private readonly XmlSerializerNamespaces _namespaces;
protected CatalogBase(String dataPath)
{
DataPath = dataPath;
Serializer = new XmlSerializer(typeof (T));
_namespaces = new XmlSerializerNamespaces();
_namespaces.Add(String.Empty, String.Empty);
}
public virtual void Write(T obj)
{
var streamWriter = new StreamWriter(DataPath);
Serializer.Serialize(streamWriter, obj, _namespaces);
streamWriter.Close();
}
public abstract IDictionary<String, T> Read();
}
Edit:
Ostrzeżenie:
Warning 1 'Ar.ViewModel.Workspaces.MaterialCatalogBase': base type 'Or.Files.CatalogBase' is not CLS-compliant C:_Center_Work_Programming_Cs\Ar\Ar\ViewModel\Workspaces\MaterialCatalogBase.cs 9 18 Ar
Edit2:
Nawet jeśli zmienię klasy jak poniżej nadal pojawia się błąd:
public abstract class CatalogBase<T> where T : class
{
protected readonly String DataPath;
protected readonly XmlSerializer Serializer;
private readonly XmlSerializerNamespaces namespaces;
protected CatalogBase(String dataPath)
{
DataPath = dataPath;
Serializer = new XmlSerializer(typeof (T));
namespaces = new XmlSerializerNamespaces();
namespaces.Add(String.Empty, String.Empty);
}
public virtual void Write(T obj)
{
var streamWriter = new StreamWriter(DataPath);
Serializer.Serialize(streamWriter, obj, namespaces);
streamWriter.Close();
}
public abstract IDictionary<String, T> Read();
}
Poza tym zapomniałem wspomnieć, że dostaję dwa (dokładnie te same błędy) z jakiegoś powodu ...?
Jaki jest dokładny komunikat ostrzegawczy jesteś otrzymywać? –
Nie jesteśmy kompilatorami, więc pokaż, gdzie otrzymujesz ostrzeżenie o niezgodności z CLS. – CodeCaster
Naprawdę nie otrzymuję ostrzeżenia, gdy kompiluję to, wszystko wygląda dobrze. –