Skip to content

Commit

Permalink
Added roslyn rules for domain event classes, application resources an…
Browse files Browse the repository at this point in the history
…d application read-models #10
  • Loading branch information
jezzsantos committed Mar 18, 2024
1 parent 4b8cfab commit 91a5740
Show file tree
Hide file tree
Showing 26 changed files with 4,870 additions and 749 deletions.
12 changes: 6 additions & 6 deletions src/AncillaryDomain/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static class Events
{
public static class EmailDelivery
{
public class Created : IDomainEvent
public sealed class Created : IDomainEvent
{
public static Created Create(Identifier id, QueuedMessageId messageId)
{
Expand All @@ -27,7 +27,7 @@ public static Created Create(Identifier id, QueuedMessageId messageId)
public required DateTime OccurredUtc { get; set; }
}

public class EmailDetailsChanged : IDomainEvent
public sealed class EmailDetailsChanged : IDomainEvent
{
public static EmailDetailsChanged Create(Identifier id, string subject, string body, EmailRecipient to)
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public static EmailDetailsChanged Create(Identifier id, string subject, string b
public required DateTime OccurredUtc { get; set; }
}

public class DeliveryAttempted : IDomainEvent
public sealed class DeliveryAttempted : IDomainEvent
{
public static DeliveryAttempted Create(Identifier id, DateTime when)
{
Expand All @@ -74,7 +74,7 @@ public static DeliveryAttempted Create(Identifier id, DateTime when)
public required string RootId { get; set; }
}

public class DeliveryFailed : IDomainEvent
public sealed class DeliveryFailed : IDomainEvent
{
public static DeliveryFailed Create(Identifier id, DateTime when)
{
Expand All @@ -93,7 +93,7 @@ public static DeliveryFailed Create(Identifier id, DateTime when)
public required string RootId { get; set; }
}

public class DeliverySucceeded : IDomainEvent
public sealed class DeliverySucceeded : IDomainEvent
{
public static DeliverySucceeded Create(Identifier id, DateTime when)
{
Expand All @@ -115,7 +115,7 @@ public static DeliverySucceeded Create(Identifier id, DateTime when)

public static class Audits
{
public class Created : IDomainEvent
public sealed class Created : IDomainEvent
{
public static Created Create(Identifier id, Identifier againstId, Optional<Identifier> organizationId,
string auditCode, Optional<string> messageTemplate, TemplateArguments templateArguments)
Expand Down
6 changes: 3 additions & 3 deletions src/BookingsDomain/BookingRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected override Result<Error> OnStateChanged(IDomainEvent @event, bool isReco

case Events.ReservationMade changed:
{
BorrowerId = changed.BorrowerId;
BorrowerId = changed.BorrowerId.ToId();
Start = changed.Start;
End = changed.End;
return Result.Ok;
Expand Down Expand Up @@ -128,14 +128,14 @@ protected override Result<Error> OnStateChanged(IDomainEvent @event, bool isReco
case Events.TripBegan changed:
{
Recorder.TraceDebug(null, "Booking {Id} has started trip {TripId} from {From}",
Id, changed.TripId!, changed.BeganFrom);
Id, changed.TripId, changed.BeganFrom);
return Result.Ok;
}

case Events.TripEnded changed:
{
Recorder.TraceDebug(null, "Booking {Id} has ended trip {TripId} at {To}",
Id, changed.TripId!, changed.EndedTo);
Id, changed.TripId, changed.EndedTo);
return Result.Ok;
}

Expand Down
22 changes: 13 additions & 9 deletions src/BookingsDomain/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace BookingsDomain;

public static class Events
{
public class Created : IDomainEvent
public sealed class Created : IDomainEvent
{
public static Created Create(Identifier id, Identifier organizationId)
{
Expand All @@ -24,7 +24,9 @@ public static Created Create(Identifier id, Identifier organizationId)
public required DateTime OccurredUtc { get; set; }
}

public class ReservationMade : IDomainEvent
#pragma warning disable SAS063
public sealed class ReservationMade : IDomainEvent
#pragma warning restore SAS063
{
public static ReservationMade Create(Identifier id, Identifier organizationId, Identifier borrowerId,
DateTime start, DateTime end)
Expand All @@ -40,7 +42,7 @@ public static ReservationMade Create(Identifier id, Identifier organizationId, I
};
}

public required Identifier BorrowerId { get; set; }
public required string BorrowerId { get; set; }

public required DateTime End { get; set; }

Expand All @@ -53,7 +55,7 @@ public static ReservationMade Create(Identifier id, Identifier organizationId, I
public required DateTime OccurredUtc { get; set; }
}

public class CarChanged : IDomainEvent
public sealed class CarChanged : IDomainEvent
{
public static CarChanged Create(Identifier id, Identifier organizationId, Identifier carId)
{
Expand All @@ -75,7 +77,7 @@ public static CarChanged Create(Identifier id, Identifier organizationId, Identi
public required DateTime OccurredUtc { get; set; }
}

public class TripAdded : IDomainEvent
public sealed class TripAdded : IDomainEvent
{
public static TripAdded Create(Identifier id, Identifier organizationId)
{
Expand All @@ -97,7 +99,9 @@ public static TripAdded Create(Identifier id, Identifier organizationId)
public required DateTime OccurredUtc { get; set; }
}

public class TripBegan : IDomainEvent
#pragma warning disable SAS063
public sealed class TripBegan : IDomainEvent
#pragma warning restore SAS063
{
public static TripBegan Create(Identifier id, Identifier organizationId, Identifier tripId,
DateTime beganAt, Location from)
Expand All @@ -119,14 +123,14 @@ public static TripBegan Create(Identifier id, Identifier organizationId, Identif

public required string OrganizationId { get; set; }

public string? TripId { get; set; }
public required string TripId { get; set; }

public required string RootId { get; set; }

public required DateTime OccurredUtc { get; set; }
}

public class TripEnded : IDomainEvent
public sealed class TripEnded : IDomainEvent
{
public static TripEnded Create(Identifier id, Identifier organizationId, Identifier tripId, DateTime beganAt,
Location from, DateTime endedAt, Location to)
Expand Down Expand Up @@ -154,7 +158,7 @@ public static TripEnded Create(Identifier id, Identifier organizationId, Identif

public required string OrganizationId { get; set; }

public string? TripId { get; set; }
public required string TripId { get; set; }

public required string RootId { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Unavailability : ReadModelEntity
{
public Optional<string> CarId { get; set; }

public UnavailabilityCausedBy CausedBy { get; set; }
public UnavailabilityCausedBy CausedBy { get; set; } = UnavailabilityCausedBy.Other;

public Optional<string> CausedByReference { get; set; }

Expand Down
12 changes: 6 additions & 6 deletions src/CarsDomain/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace CarsDomain;

public static class Events
{
public class Created : IDomainEvent
public sealed class Created : IDomainEvent
{
public static Created Create(Identifier id, Identifier organizationId)
{
Expand All @@ -27,7 +27,7 @@ public static Created Create(Identifier id, Identifier organizationId)
public required DateTime OccurredUtc { get; set; }
}

public class ManufacturerChanged : IDomainEvent
public sealed class ManufacturerChanged : IDomainEvent
{
public static ManufacturerChanged Create(Identifier id, Identifier organizationId,
Manufacturer manufacturer)
Expand Down Expand Up @@ -56,7 +56,7 @@ public static ManufacturerChanged Create(Identifier id, Identifier organizationI
public required DateTime OccurredUtc { get; set; }
}

public class OwnershipChanged : IDomainEvent
public sealed class OwnershipChanged : IDomainEvent
{
public static OwnershipChanged Create(Identifier id, Identifier organizationId, VehicleOwner owner)
{
Expand All @@ -81,7 +81,7 @@ public static OwnershipChanged Create(Identifier id, Identifier organizationId,
public required DateTime OccurredUtc { get; set; }
}

public class RegistrationChanged : IDomainEvent
public sealed class RegistrationChanged : IDomainEvent
{
public static RegistrationChanged Create(Identifier id, Identifier organizationId, LicensePlate plate)
{
Expand Down Expand Up @@ -109,7 +109,7 @@ public static RegistrationChanged Create(Identifier id, Identifier organizationI
public required DateTime OccurredUtc { get; set; }
}

public class UnavailabilitySlotAdded : IDomainEvent
public sealed class UnavailabilitySlotAdded : IDomainEvent
{
public static UnavailabilitySlotAdded Create(Identifier id, Identifier organizationId, TimeSlot slot,
CausedBy causedBy)
Expand Down Expand Up @@ -144,7 +144,7 @@ public static UnavailabilitySlotAdded Create(Identifier id, Identifier organizat
public required DateTime OccurredUtc { get; set; }
}

public class UnavailabilitySlotRemoved : IDomainEvent
public sealed class UnavailabilitySlotRemoved : IDomainEvent
{
public static UnavailabilitySlotRemoved Create(Identifier id, Identifier organizationId,
Identifier unavailabilityId)
Expand Down
36 changes: 18 additions & 18 deletions src/EndUsersDomain/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace EndUsersDomain;

public static class Events
{
public class Created : IDomainEvent
public sealed class Created : IDomainEvent
{
public static Created Create(Identifier id, UserClassification classification)
{
Expand All @@ -29,10 +29,10 @@ public static Created Create(Identifier id, UserClassification classification)

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class Registered : IDomainEvent
public sealed class Registered : IDomainEvent
{
public static Registered Create(Identifier id, Optional<EmailAddress> username,
UserClassification classification,
Expand Down Expand Up @@ -67,10 +67,10 @@ public static Registered Create(Identifier id, Optional<EmailAddress> username,

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class MembershipAdded : IDomainEvent
public sealed class MembershipAdded : IDomainEvent
{
public static MembershipAdded Create(Identifier id, Identifier organizationId, bool isDefault, Roles roles,
Features features)
Expand All @@ -89,20 +89,20 @@ public static MembershipAdded Create(Identifier id, Identifier organizationId, b

public required List<string> Features { get; set; }

public bool IsDefault { get; set; }
public required bool IsDefault { get; set; }

public string? MembershipId { get; set; }
public required string? MembershipId { get; set; }

public required string OrganizationId { get; set; }

public required List<string> Roles { get; set; }

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class MembershipDefaultChanged : IDomainEvent
public sealed class MembershipDefaultChanged : IDomainEvent
{
public static MembershipDefaultChanged Create(Identifier id, Identifier fromMembershipId,
Identifier toMembershipId)
Expand All @@ -122,10 +122,10 @@ public static MembershipDefaultChanged Create(Identifier id, Identifier fromMemb

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class MembershipRoleAssigned : IDomainEvent
public sealed class MembershipRoleAssigned : IDomainEvent
{
public static MembershipRoleAssigned Create(Identifier id, Identifier organizationId, Identifier membershipId,
Role role)
Expand All @@ -148,10 +148,10 @@ public static MembershipRoleAssigned Create(Identifier id, Identifier organizati

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class MembershipFeatureAssigned : IDomainEvent
public sealed class MembershipFeatureAssigned : IDomainEvent
{
public static MembershipFeatureAssigned Create(Identifier id, Identifier organizationId,
Identifier membershipId, Feature feature)
Expand All @@ -174,10 +174,10 @@ public static MembershipFeatureAssigned Create(Identifier id, Identifier organiz

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class PlatformRoleAssigned : IDomainEvent
public sealed class PlatformRoleAssigned : IDomainEvent
{
public static PlatformRoleAssigned Create(Identifier id, Role role)
{
Expand All @@ -193,10 +193,10 @@ public static PlatformRoleAssigned Create(Identifier id, Role role)

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}

public class PlatformFeatureAssigned : IDomainEvent
public sealed class PlatformFeatureAssigned : IDomainEvent
{
public static PlatformFeatureAssigned Create(Identifier id, Feature feature)
{
Expand All @@ -212,6 +212,6 @@ public static PlatformFeatureAssigned Create(Identifier id, Feature feature)

public required string RootId { get; set; }

public DateTime OccurredUtc { get; set; }
public required DateTime OccurredUtc { get; set; }
}
}
Loading

0 comments on commit 91a5740

Please sign in to comment.