Всем привет!
Проблема с Null-state analysis. Наследуем класс от System.Data.Common.DbCommand ==> имеем неустранимый warning на override CommandText.
Если сделать так, то имеем
warning CS8765: Nullability of type of parameter 'value' doesn't match overridden member (possibly because of nullability attributes) — подчеркивает зеленым
set:
public override string CommandText { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
Если сделать так, то имеем
warning CS8764: Nullability of return type doesn't match overridden member (possibly because of nullability attributes) — подчеркивает зеленым
get:
public override string? CommandText { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
Что вообще происходит и как его удовлетворить, устранить этот warning без suppression?
PS. Вот полный текст, может кому пригодится попробовать:
class MyDbCommand : System.Data.Common.DbCommand
{
public override string? CommandText { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } // <== неустранимый warning
public override int CommandTimeout { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override System.Data.CommandType CommandType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override bool DesignTimeVisible { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override System.Data.UpdateRowSource UpdatedRowSource { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
protected override System.Data.Common.DbConnection? DbConnection { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
protected override System.Data.Common.DbParameterCollection DbParameterCollection => throw new NotImplementedException();
protected override System.Data.Common.DbTransaction? DbTransaction { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public override void Cancel()
{
throw new NotImplementedException();
}
public override int ExecuteNonQuery()
{
throw new NotImplementedException();
}
public override object? ExecuteScalar()
{
throw new NotImplementedException();
}
public override void Prepare()
{
throw new NotImplementedException();
}
protected override System.Data.Common.DbParameter CreateDbParameter()
{
throw new NotImplementedException();
}
protected override System.Data.Common.DbDataReader ExecuteDbDataReader(System.Data.CommandBehavior behavior)
{
throw new NotImplementedException();
}
}