diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 10b0e89cd7..e1421476d1 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -368,10 +368,7 @@ namespace Tgstation.Server.Host.Components { var testMerges = updatedTestMerges ?? oldRevInfo.ActiveTestMerges.Select(x => x.TestMerge); var revInfoTestMerges = testMerges.Select( - testMerge => new RevInfoTestMerge - { - TestMerge = testMerge, - }) + testMerge => new RevInfoTestMerge(testMerge, currentRevInfo)) .ToList(); currentRevInfo.ActiveTestMerges = revInfoTestMerges; diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 8b00701f69..130718f9e5 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -228,10 +228,7 @@ namespace Tgstation.Server.Host.Components.Repository foreach (var activeTestMerge in previousRevInfo.ActiveTestMerges) lastRevisionInfo.ActiveTestMerges.Add(activeTestMerge); - lastRevisionInfo.ActiveTestMerges.Add(new RevInfoTestMerge - { - TestMerge = testMergeToAdd, - }); + lastRevisionInfo.ActiveTestMerges.Add(new RevInfoTestMerge(testMergeToAdd, lastRevisionInfo)); lastRevisionInfo.PrimaryTestMerge = testMergeToAdd; needsUpdate = true; diff --git a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs index 64b088343a..bed334b0bc 100644 --- a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs +++ b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs @@ -1,6 +1,5 @@ -using System.ComponentModel.DataAnnotations; - -#nullable disable +using System; +using System.ComponentModel.DataAnnotations; namespace Tgstation.Server.Host.Models { @@ -25,5 +24,26 @@ namespace Tgstation.Server.Host.Models /// [Required] public RevisionInformation RevisionInformation { get; set; } + + /// + /// Initializes a new instance of the class. + /// + [Obsolete("For use by EFCore only", true)] + public RevInfoTestMerge() + { + TestMerge = null!; + RevisionInformation = null!; + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + public RevInfoTestMerge(TestMerge testMerge, RevisionInformation revisionInformation) + { + TestMerge = testMerge ?? throw new ArgumentNullException(nameof(testMerge)); + RevisionInformation = revisionInformation ?? throw new ArgumentNullException(nameof(revisionInformation)); + } } }