Skip to content

Conversation

@sheptikhinv
Copy link

No description provided.

<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>

Choose a reason for hiding this comment

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

Зачем здесь все эти зависимости? Обычно они нужны только для тестирования

public List<MarkdownNode> Children { get; set; } = [];

public override string ToHtml() =>
$"<strong>{string.Concat(Children.Select(child => child.ToHtml()))}</strong>";

Choose a reason for hiding this comment

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

nit: Правильнее было бы использовать тег <b/>. Текущий чаще всего отображается также, но не на всех платформах, т.к. имеет немного более конкретный смысл


public class HeaderNode : MarkdownNode
{
public int Level { get; set; }

Choose a reason for hiding this comment

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

Как будто бы ничто не мешает задать любой другой уровень заголовка, кроме 1-6, в т.ч. отрицательный


public class BoldNode : MarkdownNode
{
public List<MarkdownNode> Children { get; set; } = [];

Choose a reason for hiding this comment

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

Хорошо бы сделать все это (в т.ч. в остальных нодах) иммутабельным. Т.е. init вместо set, IReadonlyCollection вместо List, добавить модификатор required, чтобы гарантировать наличие поля и не присваивать ничего по умолчанию

@@ -0,0 +1,9 @@
namespace Markdown.Parsing.Nodes;

public class BoldNode : MarkdownNode

Choose a reason for hiding this comment

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

Я бы по возможности делал классы sealed. Это наноопотимизация для компилятора + заставит лишний раз подумать, при возникновении необходимости наследоваться

[SetUp]
public void Setup()
{
tokenizer = new Tokenizer();

Choose a reason for hiding this comment

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

По возможности лучше создавать это внутри конкретных тестов, т.к. может возникнуть необходимость передать различные параметры + дополнительная гарантия отсутствия влияния тестов друг на друга

EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Samples", "Samples\Samples.csproj", "{C3EF41D7-50EF-4CE1-B30A-D1D81C93D7FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Markdown", "Markdown\Markdown.csproj", "{98BE1775-57AE-45F6-8921-DD3652ED05ED}"

Choose a reason for hiding this comment

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

На этом моменте понял, что реализация и тесты лежат в одном проекте. Обычно так не делают, заводят отдельный проект с названием ТестируемыйПроект.Tests, добавляют ему в зависимость тестируем проект и прочее необходимое для тестирования

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