Skip to content

Commit

Permalink
Added json ignore attributes to non-data properties. (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgernand authored Jun 8, 2024
1 parent d6e248a commit 2331946
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
next-version: 8.0.0
next-version: 8.3.0
4 changes: 3 additions & 1 deletion src/Fluxera.DomainEvents.Abstractions/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if NET7_0_OR_GREATER
using System.Numerics;
#endif
using System.Runtime.CompilerServices;
using JetBrains.Annotations;

Expand All @@ -28,7 +30,7 @@ public static string ThrowIfNullOrEmpty(string argument, [InvokerParameterName][
return argument;
}

public static string ThrowIfNullOrWhiteSpace(string argument, [InvokerParameterName][CallerArgumentExpression("argument")] string parameterName = null)
public static string ThrowIfNullOrWhiteSpace(string argument, [InvokerParameterName][CallerArgumentExpression(nameof(argument))] string parameterName = null)
{
argument = ThrowIfNull(argument, parameterName);

Expand Down
2 changes: 2 additions & 0 deletions src/Fluxera.Entity/AggregateRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using Fluxera.DomainEvents.Abstractions;
using JetBrains.Annotations;

Expand All @@ -21,6 +22,7 @@ public abstract class AggregateRoot<TAggregateRoot, TKey> : Entity<TAggregateRoo
/// <summary>
/// The domain events of this entity.
/// </summary>
[JsonIgnore]
[IgnoreDataMember]
public IReadOnlyCollection<IDomainEvent> DomainEvents => this.domainEvents.AsReadOnly();

Expand Down
3 changes: 3 additions & 0 deletions src/Fluxera.Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using System.Text.Json.Serialization;
using JetBrains.Annotations;

/// <summary>
Expand All @@ -30,11 +31,13 @@ public abstract class Entity<TEntity, TKey>
/// The unique ID of the entity.
/// </summary>
[Key]
[JsonPropertyOrder(int.MinValue)]
public virtual TKey ID { get; set; }

/// <summary>
/// Gets a flag, if the entity instance is transient (not stored to the storage).
/// </summary>
[JsonIgnore]
[IgnoreDataMember]
public virtual bool IsTransient
{
Expand Down
4 changes: 3 additions & 1 deletion src/Fluxera.Entity/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
#if NET7_0_OR_GREATER
using System.Numerics;
#endif
using System.Runtime.CompilerServices;
using JetBrains.Annotations;

Expand All @@ -28,7 +30,7 @@ public static string ThrowIfNullOrEmpty(string argument, [InvokerParameterName][
return argument;
}

public static string ThrowIfNullOrWhiteSpace(string argument, [InvokerParameterName][CallerArgumentExpression("argument")] string parameterName = null)
public static string ThrowIfNullOrWhiteSpace(string argument, [InvokerParameterName][CallerArgumentExpression(nameof(argument))] string parameterName = null)
{
argument = ThrowIfNull(argument, parameterName);

Expand Down

0 comments on commit 2331946

Please sign in to comment.