Aller au contenu

Not implemented exception (ARCH706)

Ce contenu n’est pas encore disponible dans votre langue.

Key dotnet.codequality.not-implemented-exception · Severity warning · Category codequality · Principle LiskovSubstitution

Members that throw NotImplementedException mean a subtype does not honor its contract, leading to unexpected runtime crashes.

public class CsvExporter : IExporter
{
public void Export(Report report)
{
throw new NotImplementedException();
}
}
public class CsvExporter : IExporter
{
public void Export(Report report)
{
using var writer = new StreamWriter(report.Path);
foreach (var row in report.Rows)
writer.WriteLine(string.Join(',', row));
}
}

Actually implement the functionality; if a type is not yet supported, do not implement the interface or document the unsupported behavior explicitly.