Skip to content

Commit fafbabb

Browse files
committed
Mod run code analysis
1 parent d7c1f2d commit fafbabb

File tree

15 files changed

+353
-418
lines changed

15 files changed

+353
-418
lines changed
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
1+
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
42

5-
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions
3+
/// <summary>
4+
/// Represents the marker interface for auditable entities.
5+
/// </summary>
6+
public interface IAuditableEntity
67
{
78
/// <summary>
8-
/// Represents the marker interface for auditable entities.
9+
/// Gets the created on date and time in UTC format.
910
/// </summary>
10-
public interface IAuditableEntity
11-
{
12-
/// <summary>
13-
/// Gets the created on date and time in UTC format.
14-
/// </summary>
15-
DateTime CreatedOn { get; }
11+
DateTime CreatedOn { get; }
1612

17-
/// <summary>
18-
/// Gets the modified on date and time in UTC format.
19-
/// </summary>
20-
DateTime? ModifiedOn { get; }
21-
}
13+
/// <summary>
14+
/// Gets the modified on date and time in UTC format.
15+
/// </summary>
16+
DateTime? ModifiedOn { get; }
2217
}
Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
1+
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
42

5-
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions
3+
/// <summary>
4+
/// Represents the marker interface for soft-deletable entities.
5+
/// </summary>
6+
public interface ISoftDeletableEntity
67
{
78
/// <summary>
8-
/// Represents the marker interface for soft-deletable entities.
9+
/// Gets the date and time in UTC format the entity was deleted on.
910
/// </summary>
10-
public interface ISoftDeletableEntity
11-
{
12-
/// <summary>
13-
/// Gets the date and time in UTC format the entity was deleted on.
14-
/// </summary>
15-
DateTime? DeletedOn { get; }
11+
DateTime? DeletedOn { get; }
1612

17-
/// <summary>
18-
/// Gets a value indicating whether the entity has been deleted.
19-
/// </summary>
20-
bool Deleted { get; }
21-
}
13+
/// <summary>
14+
/// Gets a value indicating whether the entity has been deleted.
15+
/// </summary>
16+
bool Deleted { get; }
2217
}
Lines changed: 42 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,60 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Modular.Monolithic.Architecture.Helper.Domain.Core;
1+
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions;
52

6-
namespace Modular.Monolithic.Architecture.Helper.Domain.Abstractions
3+
/// <summary>
4+
/// Represents the id value entities.
5+
/// </summary>
6+
public abstract class TypedIdValueBase : IEquatable<TypedIdValueBase>
77
{
88
/// <summary>
9-
/// Represents the id value entities.
9+
/// Gets or sets the entity identifier.
1010
/// </summary>
11-
public abstract class TypedIdValueBase : IEquatable<TypedIdValueBase>
12-
{
13-
/// <summary>
14-
/// Gets or sets the entity identifier.
15-
/// </summary>
16-
public Guid Value { get; private set; }
11+
public Guid Value { get; private set; }
1712

18-
protected TypedIdValueBase(Guid value)
13+
protected TypedIdValueBase(Guid value)
14+
{
15+
if (value == Guid.Empty)
1916
{
20-
if (value == Guid.Empty)
21-
{
22-
throw new InvalidOperationException("Id value cannot be empty!");
23-
}
24-
25-
Value = value;
17+
throw new InvalidOperationException("Id value cannot be empty!");
2618
}
2719

28-
/// <summary>
29-
///
30-
/// </summary>
31-
/// <param name="left"></param>
32-
/// <param name="right"></param>
33-
/// <returns></returns>
34-
public static bool operator ==(TypedIdValueBase left, TypedIdValueBase right)
35-
{
36-
if (Object.Equals(left, null))
37-
return (Object.Equals(right, null)) ? true : false;
38-
else
39-
return left.Equals(right);
40-
}
20+
Value = value;
21+
}
4122

42-
public static bool operator !=(TypedIdValueBase left, TypedIdValueBase right)
23+
/// <summary>
24+
///
25+
/// </summary>
26+
/// <param name="left"></param>
27+
/// <param name="right"></param>
28+
/// <returns></returns>
29+
public static bool operator ==(TypedIdValueBase left, TypedIdValueBase right)
30+
{
31+
if (Object.Equals(left, null))
4332
{
44-
return !(left == right);
33+
return Object.Equals(right, null);
4534
}
46-
47-
/// <inheritdoc />
48-
public bool IsTransient()
35+
else
4936
{
50-
return this.Value == default;
37+
return left.Equals(right);
5138
}
52-
53-
/// <inheritdoc />
54-
public override bool Equals(object obj)
55-
{
56-
if (ReferenceEquals(null, obj))
57-
{
58-
return false;
59-
}
39+
}
6040

61-
return obj is TypedIdValueBase other && Equals(other);
62-
}
63-
// <inheritdoc />
64-
public bool Equals(TypedIdValueBase other)
41+
public static bool operator !=(TypedIdValueBase left, TypedIdValueBase right) => !(left == right);
42+
43+
/// <inheritdoc />
44+
public bool IsTransient() => Value == default;
45+
46+
/// <inheritdoc />
47+
public override bool Equals(object obj)
48+
{
49+
if (obj is null)
6550
{
66-
return this.Value == other?.Value;
51+
return false;
6752
}
68-
/// <inheritdoc />
69-
public override int GetHashCode() => Value.GetHashCode();
53+
54+
return obj is TypedIdValueBase other && Equals(other);
7055
}
56+
// <inheritdoc />
57+
public bool Equals(TypedIdValueBase other) => Value == other?.Value;
58+
/// <inheritdoc />
59+
public override int GetHashCode() => Value.GetHashCode();
7160
}
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
4-
using Modular.Monolithic.Architecture.Helper.Domain.Errors;
1+
using Modular.Monolithic.Architecture.Helper.Domain.Errors;
52

6-
namespace Modular.Monolithic.Architecture.Helper.Domain.BusinessRules
3+
namespace Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
4+
5+
public interface IBusinessRule
76
{
8-
public interface IBusinessRule
9-
{
10-
bool IsFail();
11-
Error Error { get; }
12-
}
7+
bool IsFail();
8+
Error Error { get; }
139
}
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Text;
1+
namespace Modular.Monolithic.Architecture.Helper.Domain.Core;
42

5-
namespace Modular.Monolithic.Architecture.Helper.Domain.Core
6-
{
7-
/// <summary>
8-
///
9-
/// </summary>
10-
public abstract class AggregateRoot : Entity { }
11-
}
3+
/// <summary>
4+
///
5+
/// </summary>
6+
public abstract class AggregateRoot : Entity { }
Lines changed: 47 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,58 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
1+
using Modular.Monolithic.Architecture.Helper.Domain.BusinessRules;
42
using Modular.Monolithic.Architecture.Helper.Domain.Events;
53
using Modular.Monolithic.Architecture.Helper.Domain.Exceptions;
64

7-
namespace Modular.Monolithic.Architecture.Helper.Domain.Core
5+
namespace Modular.Monolithic.Architecture.Helper.Domain.Core;
6+
7+
/// <summary>
8+
/// Represents the base class that all entities derive from.
9+
/// </summary>
10+
public abstract class Entity
811
{
12+
13+
private List<IDomainEvent> _domainEvents;
14+
915
/// <summary>
10-
/// Represents the base class that all entities derive from.
16+
/// Domain events occurred.
1117
/// </summary>
12-
public abstract class Entity
18+
public IReadOnlyCollection<IDomainEvent>? DomainEvents => _domainEvents?.AsReadOnly();
19+
/// <summary>
20+
/// Initializes a new instance of the <see cref="Entity"/> class.
21+
/// </summary>
22+
/// <remarks>
23+
/// Required by EF Core.
24+
/// </remarks>
25+
protected Entity()
1326
{
14-
15-
private List<IDomainEvent> _domainEvents;
16-
17-
/// <summary>
18-
/// Domain events occurred.
19-
/// </summary>
20-
public IReadOnlyCollection<IDomainEvent> DomainEvents => _domainEvents?.AsReadOnly();
21-
/// <summary>
22-
/// Initializes a new instance of the <see cref="Entity"/> class.
23-
/// </summary>
24-
/// <remarks>
25-
/// Required by EF Core.
26-
/// </remarks>
27-
protected Entity()
28-
{
29-
}
30-
/// <summary>
31-
///
32-
/// </summary>
33-
/// <param name="eventItem"></param>
34-
public void AddDomainEvent(IDomainEvent eventItem)
35-
{
36-
_domainEvents = _domainEvents ?? new List<IDomainEvent>();
37-
_domainEvents.Add(eventItem);
38-
}
39-
/// <summary>
40-
///
41-
/// </summary>
42-
/// <param name="eventItem"></param>
43-
public void RemoveDomainEvent(IDomainEvent eventItem)
44-
{
45-
_domainEvents?.Remove(eventItem);
46-
}
47-
/// <summary>
48-
///
49-
/// </summary>
50-
public void ClearDomainEvents()
51-
{
52-
_domainEvents?.Clear();
53-
}
54-
/// <summary>
55-
///
56-
/// </summary>
57-
/// <param name="rule"></param>
58-
/// <exception cref="BusinessRuleValidationException"></exception>
59-
protected void CheckRule(IBusinessRule rule)
27+
}
28+
/// <summary>
29+
///
30+
/// </summary>
31+
/// <param name="eventItem"></param>
32+
public void AddDomainEvent(IDomainEvent eventItem)
33+
{
34+
_domainEvents ??= [];
35+
_domainEvents.Add(eventItem);
36+
}
37+
/// <summary>
38+
///
39+
/// </summary>
40+
/// <param name="eventItem"></param>
41+
public void RemoveDomainEvent(IDomainEvent eventItem) => _domainEvents?.Remove(eventItem);
42+
/// <summary>
43+
///
44+
/// </summary>
45+
public void ClearDomainEvents() => _domainEvents?.Clear();
46+
/// <summary>
47+
///
48+
/// </summary>
49+
/// <param name="rule"></param>
50+
/// <exception cref="BusinessRuleValidationException"></exception>
51+
protected void CheckRule(IBusinessRule rule)
52+
{
53+
if (rule.IsFail())
6054
{
61-
if (rule.IsFail())
62-
{
63-
throw new BusinessRuleValidationException(rule);
64-
}
55+
throw new BusinessRuleValidationException(rule);
6556
}
6657
}
6758
}

0 commit comments

Comments
 (0)