From faed173160e8646aa8ac289b0b036173146c9b44 Mon Sep 17 00:00:00 2001 From: "mranotmillion@gmail.com" Date: Tue, 23 Jul 2024 20:38:20 +0330 Subject: [PATCH 1/2] Simplify UpdateTags by removing redundant null check This commit removes the unnecessary null check for _tags in the UpdateTags method. Since IReadOnlyList tags is not nullable, _tags is guaranteed to be initialized before UpdateTags is called. Therefore, the check if (_tags is not null) is redundant and can be safely removed. --- src/Blogger.Domain/ArticleAggregate/Article.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Blogger.Domain/ArticleAggregate/Article.cs b/src/Blogger.Domain/ArticleAggregate/Article.cs index 9820e2b..3a2b45c 100644 --- a/src/Blogger.Domain/ArticleAggregate/Article.cs +++ b/src/Blogger.Domain/ArticleAggregate/Article.cs @@ -86,8 +86,7 @@ public void UpdateDraft(string title, string summary, string body) public void UpdateTags(IReadOnlyList tags) { - if (_tags is not null) - _tags.Clear(); + _tags.Clear(); AddTags(tags); } From 6165766e67061778e5eb0637b2eadb048d5a25d4 Mon Sep 17 00:00:00 2001 From: "mranotmillion@gmail.com" Date: Tue, 23 Jul 2024 20:57:46 +0330 Subject: [PATCH 2/2] Simplify ToString implementation This commit simplifies the ToString implementation by directly returning the Value property instead of calling Value.ToString(). --- src/Blogger.Domain/ArticleAggregate/Tag.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blogger.Domain/ArticleAggregate/Tag.cs b/src/Blogger.Domain/ArticleAggregate/Tag.cs index 46a7991..f4e9f8b 100644 --- a/src/Blogger.Domain/ArticleAggregate/Tag.cs +++ b/src/Blogger.Domain/ArticleAggregate/Tag.cs @@ -20,6 +20,6 @@ public static Tag Create(string tagValue) public override string ToString() { - return Value.ToString(); + return Value; } }