Skip to content

Comments

Null elements#13

Open
Andrw-404 wants to merge 1 commit intomainfrom
nullElements(23.05)
Open

Null elements#13
Andrw-404 wants to merge 1 commit intomainfrom
nullElements(23.05)

Conversation

@Andrw-404
Copy link
Owner

No description provided.

Comment on lines +2 to +4
// ACTION REQUIRED: This file was automatically added to your project, but it
// will not take effect until additional steps are taken to enable it. See the
// following page for additional information:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут говорится, что надо конфигурацию применить и удалить этот комментарий

[*.cs]

# SA1600: Elements should be documented
dotnet_diagnostic.SA1600.severity = none

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это стоило выключать только для тестов, для всего проекта не надо

// Copyright (c) Kalinin Andrew. All rights reserved.
// </copyright>

namespace NullElements.Tests

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Используйте file-scoped namespaces, так сейчас не пишут уже

{
var testList = new MyList<string>();
testList.Add("hello");
testList.Add(null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут стоило явно заглушить предупреждения nullability, хотя бы с помощью оператора !. Потому что собираться должно без предупреждений.

{
if (list == null)
{
throw new ArgumentNullException(nameof(list));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ArgumentNullException.ThrowIfNull

{
for (int i = 0; i < this.count; ++i)
{
yield return this.items[i];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Так оно не будет проверять на то, что список не поменялся. Можно было просто запомнить count в локальной переменной и на каждой итерации сравнивать её с текущим count

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Использовали бы =>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants