diff --git a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql
index d338b11bcf..1b6609bb04 100644
--- a/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql
+++ b/src/Tgstation.Server.Client.GraphQL/GQL/Queries/ReadCurrentUser.graphql
@@ -43,10 +43,10 @@ query ReadCurrentUser {
canSetOnline
}
}
-# Needs https://github.com/ChilliCream/graphql-platform/issues/8313
-# createdBy {
-# id
-# name
+ createdById # Need https://github.com/ChilliCream/graphql-platform/issues/8313 to remove
+ createdBy {
+ id
+ name
}
}
}
diff --git a/src/Tgstation.Server.Host/Authority/Core/Projectable{TQueried,TResult}.cs b/src/Tgstation.Server.Host/Authority/Core/Projectable{TQueried,TResult}.cs
index 9d8231e33d..5161f79ce4 100644
--- a/src/Tgstation.Server.Host/Authority/Core/Projectable{TQueried,TResult}.cs
+++ b/src/Tgstation.Server.Host/Authority/Core/Projectable{TQueried,TResult}.cs
@@ -18,7 +18,6 @@ namespace Tgstation.Server.Host.Authority.Core
/// The transformed result .
public sealed class Projectable
where TQueried : EntityId
- where TResult : notnull
{
///
/// The underlying . Should only select one entity.
@@ -195,7 +194,8 @@ namespace Tgstation.Server.Host.Authority.Core
public async ValueTask> Resolve(Func, IQueryable>> projection)
{
ArgumentNullException.ThrowIfNull(projection);
- var finalQueryable = projection(query)
+ var projectedQueryable = projection(query);
+ var finalQueryable = projectedQueryable
.Select(selector);
var selection = await finalQueryable
.FirstOrDefaultAsync(cancellationToken);
diff --git a/src/Tgstation.Server.Host/Authority/LoginAuthority.cs b/src/Tgstation.Server.Host/Authority/LoginAuthority.cs
index 8f150845d4..3eff420f70 100644
--- a/src/Tgstation.Server.Host/Authority/LoginAuthority.cs
+++ b/src/Tgstation.Server.Host/Authority/LoginAuthority.cs
@@ -257,7 +257,7 @@ namespace Tgstation.Server.Host.Authority
Logger.LogDebug("User ID {userId}'s password hash needs a refresh, updating database.", user.Id);
var updatedUser = new User
{
- Id = user.Id,
+ Id = user.Require(x => x.Id),
};
DatabaseContext.Users.Attach(updatedUser);
updatedUser.PasswordHash = user.PasswordHash;
diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
index 2aeca4f8f3..7b917e4b82 100644
--- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs
@@ -326,7 +326,7 @@ namespace Tgstation.Server.Host.Components.Chat
if (originalChatBot != null)
activeChatBots.Remove(originalChatBot);
- activeChatBots.Add(new Models.ChatBot(newSettings.Channels)
+ activeChatBots.Add(new Models.ChatBot
{
Id = newSettings.Id,
ConnectionString = newSettings.ConnectionString,
@@ -334,6 +334,7 @@ namespace Tgstation.Server.Host.Components.Chat
Name = newSettings.Name,
ReconnectionInterval = newSettings.ReconnectionInterval,
Provider = newSettings.Provider,
+ Channels = newSettings.Channels,
});
}
diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs
index 573473c2f6..d255b6ce45 100644
--- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs
+++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs
@@ -81,7 +81,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
#pragma warning disable CA1506
public async ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
{
- IEnumerable results;
+ IEnumerable<(int Number, string TargetCommitSha)> results;
var splits = arguments.Split(' ');
var hasRepo = splits.Any(x => x.Equals("--repo", StringComparison.OrdinalIgnoreCase));
var hasStaged = splits.Any(x => x.Equals("--staged", StringComparison.OrdinalIgnoreCase));
@@ -114,17 +114,22 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
results = null!;
await databaseContextFactory.UseContext(
- async db => results = await db
- .RevisionInformations
- .Where(x => x.Instance!.Id == instance.Id && x.CommitSha == head)
- .SelectMany(x => x.ActiveTestMerges!)
- .Select(x => x.TestMerge)
- .Select(x => new Models.TestMerge
- {
- Number = x.Number,
- TargetCommitSha = x.TargetCommitSha,
- })
- .ToListAsync(cancellationToken));
+ async db =>
+ {
+ var anonResults = await db
+ .RevisionInformations
+ .Where(x => x.Instance!.Id == instance.Id && x.CommitSha == head)
+ .SelectMany(x => x.ActiveTestMerges!)
+ .Select(x => x.TestMerge)
+ .Select(x => new
+ {
+ x.Number,
+ TargetCommitSha = x.TargetCommitSha!,
+ })
+ .ToListAsync(cancellationToken);
+ results = anonResults
+ .Select(anonResult => (anonResult.Number, anonResult.TargetCommitSha));
+ });
}
else if (watchdog.Status == WatchdogStatus.Offline)
return new MessageContent
@@ -143,7 +148,12 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
compileJobToUse = null;
}
- results = compileJobToUse?.RevisionInformation.ActiveTestMerges?.Select(x => x.TestMerge).ToList() ?? Enumerable.Empty();
+ results = compileJobToUse
+ ?.RevisionInformation
+ .ActiveTestMerges
+ ?.Select(x => (x.TestMerge.Number, TargetCommitSha: x.TestMerge.TargetCommitSha!))
+ .ToList()
+ ?? Enumerable.Empty<(int Number, string TargetCommitSha)>();
}
return new MessageContent
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
index 8c920d0cbb..3f44f8d0b1 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs
@@ -86,7 +86,7 @@ namespace Tgstation.Server.Host.Components.Deployment
readonly CancellationTokenSource lockLogCts;
///
- /// Map of s to locks on them.
+ /// Map of s to locks on them.
///
readonly Dictionary jobLockManagers;
diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
index c702b1fa8a..100ff6d656 100644
--- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
+++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs
@@ -315,10 +315,7 @@ namespace Tgstation.Server.Host.Components.Deployment
CommitSha = repoSha,
Timestamp = await repo.TimestampCommit(repoSha, cancellationToken),
OriginCommitSha = repoSha,
- Instance = new Models.Instance
- {
- Id = metadata.Id,
- },
+ InstanceId = metadata.Require(x => x.Id),
ActiveTestMerges = new List(),
};
@@ -335,6 +332,7 @@ namespace Tgstation.Server.Host.Components.Deployment
}
});
+ var notNullRevInfo = revInfo!;
Models.CompileJob? oldCompileJob;
using (repo)
{
@@ -346,7 +344,7 @@ namespace Tgstation.Server.Host.Components.Deployment
compileJob = await Compile(
job,
oldCompileJob,
- revInfo!,
+ notNullRevInfo,
dreamMakerSettings!,
ddSettings!,
repo!,
@@ -367,7 +365,7 @@ namespace Tgstation.Server.Host.Components.Deployment
var fullRevInfo = compileJob.RevisionInformation;
compileJob.RevisionInformation = new Models.RevisionInformation
{
- Id = revInfo!.Id,
+ Id = notNullRevInfo.Id,
};
databaseContext.Jobs.Attach(compileJob.Job);
@@ -523,8 +521,11 @@ namespace Tgstation.Server.Host.Components.Deployment
repository.RemoteRepositoryName,
localCommitExistsOnRemote);
- var compileJob = new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString())
+ var compileJob = new Models.CompileJob
{
+ Job = job,
+ RevisionInformation = revisionInformation,
+ EngineVersion = engineLock.Version.ToString(),
DirectoryName = Guid.NewGuid(),
DmeName = dreamMakerSettings.ProjectName,
RepositoryOrigin = repository.Origin.ToString(),
diff --git a/src/Tgstation.Server.Host/Extensions/QueryContextExtensions.cs b/src/Tgstation.Server.Host/Extensions/QueryContextExtensions.cs
index 3a4bacb966..117e5da22a 100644
--- a/src/Tgstation.Server.Host/Extensions/QueryContextExtensions.cs
+++ b/src/Tgstation.Server.Host/Extensions/QueryContextExtensions.cs
@@ -18,9 +18,10 @@ namespace Tgstation.Server.Host.Extensions
/// The parent .
/// The child .
/// The to transform.
+ /// A used in cas the conversion does not yield a .
/// A new for that is functionally identical to the original .
- public static QueryContext UpcastFrom(this QueryContext queryContext)
- where TChild : TParent
+ public static QueryContext UpcastFrom(this QueryContext queryContext, Expression> fallback)
+ where TChild : class, TParent
{
ArgumentNullException.ThrowIfNull(queryContext);
@@ -28,13 +29,14 @@ namespace Tgstation.Server.Host.Extensions
Expression>? selector = null;
if (queryContext.Selector != null)
{
- Expression> upcast = parent => (TChild)parent!;
+ Expression, TChild>> upcast = (parent, fallback) => (parent as TChild) ?? fallback();
selector = Expression.Lambda>(
Expression.Invoke(
upcast,
Expression.Invoke(
queryContext.Selector,
- parameter)),
+ parameter),
+ fallback),
parameter);
}
diff --git a/src/Tgstation.Server.Host/GraphQL/Types/User.cs b/src/Tgstation.Server.Host/GraphQL/Types/User.cs
index 16917f1086..738c3b7748 100644
--- a/src/Tgstation.Server.Host/GraphQL/Types/User.cs
+++ b/src/Tgstation.Server.Host/GraphQL/Types/User.cs
@@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.GraphQL.Types
/// A user registered in the server.
///
[Node]
- public sealed class User : UserName
+ public sealed class User : NamedEntity, IUserName
{
///
[IsProjected(true)]
@@ -133,16 +133,24 @@ namespace Tgstation.Server.Host.GraphQL.Types
ArgumentNullException.ThrowIfNull(userAuthority);
// This one is particular and cannot be data-loaded due to necessitating a different parameter
- var user = await userAuthority.InvokeTransformable(
- authority => authority.GetId(CreatedById, true, cancellationToken),
- queryContext?.UpcastFrom());
- if (user == null)
- throw new InvalidOperationException($"Query for created by of user ID {CreatedById} returned null!");
+ try
+ {
+ var temp = (User)null!;
+ var user = await userAuthority.InvokeTransformable(
+ authority => authority.GetId(CreatedById, true, cancellationToken),
+ queryContext?.UpcastFrom(() => temp));
+ if (user == null)
+ throw new InvalidOperationException($"Query for created by of user ID {CreatedById} returned null!");
- if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName))
- return new UserName(user);
+ if (user.CanonicalName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName))
+ return new UserName(user);
- return user;
+ return user;
+ }
+ catch
+ {
+ throw;
+ }
}
///
diff --git a/src/Tgstation.Server.Host/Models/ChatBot.cs b/src/Tgstation.Server.Host/Models/ChatBot.cs
index 908581eff5..6b54f41abc 100644
--- a/src/Tgstation.Server.Host/Models/ChatBot.cs
+++ b/src/Tgstation.Server.Host/Models/ChatBot.cs
@@ -1,6 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
+using System.Collections.Generic;
using System.Linq;
using Tgstation.Server.Api.Models.Response;
@@ -23,30 +21,12 @@ namespace Tgstation.Server.Host.Models
///
/// The parent .
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
/// See .
///
- public ICollection Channels { get; set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public ChatBot()
- : this(new List())
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The value of .
- public ChatBot(ICollection channels)
- {
- Channels = channels ?? throw new ArgumentNullException(nameof(channels));
- }
+ public ICollection Channels { get; set; } = null!; // recommended by EF
///
public ChatBotResponse ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs
index 9263d2f9a6..fb62b6ff18 100644
--- a/src/Tgstation.Server.Host/Models/ChatChannel.cs
+++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs
@@ -33,7 +33,7 @@ namespace Tgstation.Server.Host.Models
///
/// The .
///
- public ChatBot? ChatSettings { get; set; }
+ public ChatBot ChatSettings { get; set; } = null!; // recommended by EF
///
/// Convert to a .
diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs
index d316f18bd3..13acbf1dce 100644
--- a/src/Tgstation.Server.Host/Models/CompileJob.cs
+++ b/src/Tgstation.Server.Host/Models/CompileJob.cs
@@ -1,7 +1,5 @@
using System;
-using System.ComponentModel.DataAnnotations;
-using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
namespace Tgstation.Server.Host.Models
@@ -12,25 +10,22 @@ namespace Tgstation.Server.Host.Models
///
/// See .
///
- [Required]
- public Job Job { get; set; }
+ public required Job Job { get; set; }
///
- /// The of .
+ /// The of .
///
- public long JobId { get; set; }
+ public long JobId { get; set; } // Needed to determine the dependent side of the FK relationship
///
/// See .
///
- [Required]
- public RevisionInformation RevisionInformation { get; set; }
+ public required RevisionInformation RevisionInformation { get; set; }
///
/// The the was made with in string form.
///
- [Required]
- public string EngineVersion { get; set; }
+ public required string EngineVersion { get; set; }
///
/// Backing field for of .
@@ -81,47 +76,6 @@ namespace Tgstation.Server.Host.Models
}
}
- ///
- /// Initializes a new instance of the class.
- ///
- [Obsolete("For use by EFCore only", true)]
- public CompileJob()
- : this(null!, null!, null!, false)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The value of .
- /// The value of .
- /// The value of .
- public CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion)
- : this(job, revisionInformation, engineVersion, true)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The value of .
- /// The value of .
- /// The value of .
- /// If , , and should be checked for nulls.
- CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, bool nullChecks)
- {
- if (nullChecks)
- {
- ArgumentNullException.ThrowIfNull(job);
- ArgumentNullException.ThrowIfNull(revisionInformation);
- ArgumentNullException.ThrowIfNull(engineVersion);
- }
-
- Job = job;
- RevisionInformation = revisionInformation;
- EngineVersion = engineVersion;
- }
-
///
public CompileJobResponse ToApi() => new()
{
diff --git a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
index 0da7f22079..0db3379dab 100644
--- a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
+++ b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs
@@ -1,6 +1,4 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace Tgstation.Server.Host.Models
+namespace Tgstation.Server.Host.Models
{
///
public sealed class DreamDaemonSettings : Api.Models.Internal.DreamDaemonSettings
@@ -18,7 +16,6 @@ namespace Tgstation.Server.Host.Models
///
/// The parent .
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
}
}
diff --git a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
index 3904c8ad5d..b66f120d1d 100644
--- a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
+++ b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs
@@ -1,6 +1,4 @@
-using System.ComponentModel.DataAnnotations;
-
-using Tgstation.Server.Api.Models.Response;
+using Tgstation.Server.Api.Models.Response;
namespace Tgstation.Server.Host.Models
{
@@ -20,8 +18,7 @@ namespace Tgstation.Server.Host.Models
///
/// The parent .
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
public DreamMakerResponse ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs
index e793c2959c..ae455e5fe6 100644
--- a/src/Tgstation.Server.Host/Models/Instance.cs
+++ b/src/Tgstation.Server.Host/Models/Instance.cs
@@ -17,17 +17,17 @@ namespace Tgstation.Server.Host.Models
///
/// The for the .
///
- public DreamMakerSettings? DreamMakerSettings { get; set; }
+ public DreamMakerSettings DreamMakerSettings { get; set; } = null!; // recommended by EF
///
/// The for the .
///
- public DreamDaemonSettings? DreamDaemonSettings { get; set; }
+ public DreamDaemonSettings DreamDaemonSettings { get; set; } = null!; // recommended by EF
///
/// The for the .
///
- public RepositorySettings? RepositorySettings { get; set; }
+ public RepositorySettings RepositorySettings { get; set; } = null!; // recommended by EF
///
/// The of the the server in the swarm this instance belongs to.
@@ -37,33 +37,22 @@ namespace Tgstation.Server.Host.Models
///
/// The s in the .
///
- public ICollection InstancePermissionSets { get; set; }
+ public ICollection InstancePermissionSets { get; set; } = null!; // recommended by EF
///
/// The s for the .
///
- public ICollection ChatSettings { get; set; }
+ public ICollection ChatSettings { get; set; } = null!; // recommended by EF
///
/// The s in the .
///
- public ICollection RevisionInformations { get; set; }
+ public ICollection RevisionInformations { get; set; } = null!; // recommended by EF
///
/// The s in the .
///
- public ICollection Jobs { get; set; }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public Instance()
- {
- InstancePermissionSets = new List();
- ChatSettings = new List();
- RevisionInformations = new List();
- Jobs = new List();
- }
+ public ICollection Jobs { get; set; } = null!; // recommended by EF
///
public InstanceResponse ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs
index be4e5357d1..fb8a27c28c 100644
--- a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs
+++ b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs
@@ -1,6 +1,4 @@
-using System.ComponentModel.DataAnnotations;
-
-using Tgstation.Server.Api.Models.Response;
+using Tgstation.Server.Api.Models.Response;
namespace Tgstation.Server.Host.Models
{
@@ -20,14 +18,12 @@ namespace Tgstation.Server.Host.Models
///
/// The the belongs to.
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
/// The the belongs to.
///
- [Required]
- public PermissionSet? PermissionSet { get; set; }
+ public PermissionSet PermissionSet { get; set; } = null!; // recommended by EF
///
public InstancePermissionSetResponse ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs
index 521e671be8..8358cd85bc 100644
--- a/src/Tgstation.Server.Host/Models/Job.cs
+++ b/src/Tgstation.Server.Host/Models/Job.cs
@@ -1,6 +1,5 @@
using System;
using System.ComponentModel;
-using System.ComponentModel.DataAnnotations;
using System.Linq;
using Tgstation.Server.Api.Models;
@@ -17,8 +16,7 @@ namespace Tgstation.Server.Host.Models
///
/// See .
///
- [Required]
- public User? StartedBy { get; set; }
+ public User StartedBy { get; set; } = null!; // recommended by EF
///
/// See .
@@ -28,8 +26,7 @@ namespace Tgstation.Server.Host.Models
///
/// The the job belongs to if any.
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
/// Creates a new job for registering in the .
@@ -91,7 +88,7 @@ namespace Tgstation.Server.Host.Models
/// The value of .
Job(JobCode code, User? startedBy, Api.Models.Instance instance, RightsType? cancelRightsType, ulong? cancelRight)
{
- StartedBy = startedBy;
+ StartedBy = startedBy!; // allowed to be null here, set to TGS user if so later
ArgumentNullException.ThrowIfNull(instance);
Instance = new Instance
{
diff --git a/src/Tgstation.Server.Host/Models/OAuthConnection.cs b/src/Tgstation.Server.Host/Models/OAuthConnection.cs
index c5979cbaf6..0b4e02aaa2 100644
--- a/src/Tgstation.Server.Host/Models/OAuthConnection.cs
+++ b/src/Tgstation.Server.Host/Models/OAuthConnection.cs
@@ -1,6 +1,4 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace Tgstation.Server.Host.Models
+namespace Tgstation.Server.Host.Models
{
///
public sealed class OAuthConnection : Api.Models.OAuthConnection,
@@ -19,8 +17,7 @@ namespace Tgstation.Server.Host.Models
///
/// The owning .
///
- [Required]
- public User? User { get; set; }
+ public User User { get; set; } = null!; // recommended by EF
///
public Api.Models.OAuthConnection ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/OidcConnection.cs b/src/Tgstation.Server.Host/Models/OidcConnection.cs
index c76f81b0f9..5544da767b 100644
--- a/src/Tgstation.Server.Host/Models/OidcConnection.cs
+++ b/src/Tgstation.Server.Host/Models/OidcConnection.cs
@@ -20,7 +20,7 @@ namespace Tgstation.Server.Host.Models
/// The owning .
///
[Required]
- public User? User { get; set; }
+ public User User { get; set; } = null!; // recommended by EF
///
public Api.Models.OidcConnection ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/PermissionSet.cs b/src/Tgstation.Server.Host/Models/PermissionSet.cs
index 1160ca0e4f..25a5177771 100644
--- a/src/Tgstation.Server.Host/Models/PermissionSet.cs
+++ b/src/Tgstation.Server.Host/Models/PermissionSet.cs
@@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Models
///
/// The s associated with the .
///
- public ICollection? InstancePermissionSets { get; set; }
+ public ICollection InstancePermissionSets { get; set; } = null!; // recommended by EF
///
/// Convert the to it's API form.
diff --git a/src/Tgstation.Server.Host/Models/ReattachInformation.cs b/src/Tgstation.Server.Host/Models/ReattachInformation.cs
index 49360cf3e5..621a592675 100644
--- a/src/Tgstation.Server.Host/Models/ReattachInformation.cs
+++ b/src/Tgstation.Server.Host/Models/ReattachInformation.cs
@@ -1,5 +1,4 @@
using System;
-using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Host.Models
{
@@ -11,8 +10,7 @@ namespace Tgstation.Server.Host.Models
///
/// The for the .
///
- [Required]
- public CompileJob? CompileJob { get; set; }
+ public CompileJob CompileJob { get; set; } = null!; // recommended by EF
///
/// The of .
diff --git a/src/Tgstation.Server.Host/Models/RepositorySettings.cs b/src/Tgstation.Server.Host/Models/RepositorySettings.cs
index 9f36e2f123..22cf87508d 100644
--- a/src/Tgstation.Server.Host/Models/RepositorySettings.cs
+++ b/src/Tgstation.Server.Host/Models/RepositorySettings.cs
@@ -1,6 +1,4 @@
-using System.ComponentModel.DataAnnotations;
-
-using Tgstation.Server.Api.Models.Response;
+using Tgstation.Server.Api.Models.Response;
namespace Tgstation.Server.Host.Models
{
@@ -20,8 +18,7 @@ namespace Tgstation.Server.Host.Models
///
/// The parent .
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
public RepositoryResponse ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs
index bed334b0bc..7f229b1e83 100644
--- a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs
+++ b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs
@@ -1,5 +1,4 @@
using System;
-using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Host.Models
{
@@ -16,14 +15,12 @@ namespace Tgstation.Server.Host.Models
///
/// The .
///
- [Required]
- public TestMerge TestMerge { get; set; }
+ public TestMerge TestMerge { get; set; } = null!; // recommended by EF
///
/// The .
///
- [Required]
- public RevisionInformation RevisionInformation { get; set; }
+ public RevisionInformation RevisionInformation { get; set; } = null!; // recommended by EF
///
/// Initializes a new instance of the class.
@@ -31,8 +28,6 @@ namespace Tgstation.Server.Host.Models
[Obsolete("For use by EFCore only", true)]
public RevInfoTestMerge()
{
- TestMerge = null!;
- RevisionInformation = null!;
}
///
diff --git a/src/Tgstation.Server.Host/Models/RevisionInformation.cs b/src/Tgstation.Server.Host/Models/RevisionInformation.cs
index d683e9c8b7..e40be1a579 100644
--- a/src/Tgstation.Server.Host/Models/RevisionInformation.cs
+++ b/src/Tgstation.Server.Host/Models/RevisionInformation.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace Tgstation.Server.Host.Models
@@ -21,8 +20,7 @@ namespace Tgstation.Server.Host.Models
///
/// The the belongs to.
///
- [Required]
- public Instance? Instance { get; set; }
+ public Instance Instance { get; set; } = null!; // recommended by EF
///
/// See .
@@ -32,12 +30,12 @@ namespace Tgstation.Server.Host.Models
///
/// See .
///
- public ICollection? ActiveTestMerges { get; set; }
+ public ICollection ActiveTestMerges { get; set; } = null!; // recommended by EF
///
/// See s made from this .
///
- public ICollection? CompileJobs { get; set; }
+ public ICollection CompileJobs { get; set; } = null!; // recommended by EF
///
public Api.Models.RevisionInformation ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/TestMerge.cs b/src/Tgstation.Server.Host/Models/TestMerge.cs
index 1aaf31594a..871837f820 100644
--- a/src/Tgstation.Server.Host/Models/TestMerge.cs
+++ b/src/Tgstation.Server.Host/Models/TestMerge.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
namespace Tgstation.Server.Host.Models
{
@@ -10,24 +9,22 @@ namespace Tgstation.Server.Host.Models
///
/// See .
///
- [Required]
- public User? MergedBy { get; set; }
+ public User MergedBy { get; set; } = null!; // recommended by EF
///
/// The initial the was merged with.
///
- [Required]
- public RevisionInformation? PrimaryRevisionInformation { get; set; }
+ public RevisionInformation PrimaryRevisionInformation { get; set; } = null!; // recommended by EF
///
/// Foreign key for .
///
- public long? PrimaryRevisionInformationId { get; set; }
+ public long PrimaryRevisionInformationId { get; set; }
///
/// All the for the .
///
- public ICollection? RevisonInformations { get; set; }
+ public ICollection RevisonInformations { get; set; } = null!; // recommended by EF
///
public Api.Models.TestMerge ToApi() => new()
diff --git a/src/Tgstation.Server.Host/Models/User.cs b/src/Tgstation.Server.Host/Models/User.cs
index 11f7da469b..873e176b19 100644
--- a/src/Tgstation.Server.Host/Models/User.cs
+++ b/src/Tgstation.Server.Host/Models/User.cs
@@ -48,9 +48,8 @@ namespace Tgstation.Server.Host.Models
///
/// The uppercase invariant of .
///
- [Required]
[StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)]
- public string? CanonicalName { get; set; }
+ public string CanonicalName { get; set; } = null!; // recommended by EF
///
/// When was last changed.
@@ -60,22 +59,22 @@ namespace Tgstation.Server.Host.Models
///
/// s created by this .
///
- public ICollection? CreatedUsers { get; set; }
+ public ICollection CreatedUsers { get; set; } = null!; // recommended by EF
///
/// The s made by the .
///
- public ICollection? TestMerges { get; set; }
+ public ICollection TestMerges { get; set; } = null!; // recommended by EF
///
/// The s for the .
///
- public ICollection? OAuthConnections { get; set; }
+ public ICollection OAuthConnections { get; set; } = null!; // recommended by EF
///
/// The s for the .
///
- public ICollection? OidcConnections { get; set; }
+ public ICollection OidcConnections { get; set; } = null!; // recommended by EF
///
/// Change a into a .
diff --git a/src/Tgstation.Server.Host/Models/UserGroup.cs b/src/Tgstation.Server.Host/Models/UserGroup.cs
index 255815dca0..cd4eab2465 100644
--- a/src/Tgstation.Server.Host/Models/UserGroup.cs
+++ b/src/Tgstation.Server.Host/Models/UserGroup.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
using System.Linq;
using Tgstation.Server.Api.Models;
@@ -16,13 +15,12 @@ namespace Tgstation.Server.Host.Models
///
/// The the has.
///
- [Required]
- public PermissionSet? PermissionSet { get; set; }
+ public required PermissionSet PermissionSet { get; set; } = null!; // recommended by EF
///
/// The s the has.
///
- public required ICollection Users { get; set; }
+ public required ICollection Users { get; set; } = null!; // recommended by EF
///
/// Convert the to it's API form.
diff --git a/tests/Tgstation.Server.Tests/Live/UsersTest.cs b/tests/Tgstation.Server.Tests/Live/UsersTest.cs
index 4af8dd3173..ac406e1d6e 100644
--- a/tests/Tgstation.Server.Tests/Live/UsersTest.cs
+++ b/tests/Tgstation.Server.Tests/Live/UsersTest.cs
@@ -83,8 +83,7 @@ namespace Tgstation.Server.Tests.Live
&& restResult.Name == gqlUser.Name
&& (restResult.CreatedAt.Value.Ticks / 10000) == (gqlUser.CreatedAt.Ticks / 10000)
&& restResult.SystemIdentifier == gqlUser.SystemIdentifier
-// && restResult.CreatedBy.Name == gqlUser.CreatedBy.Name // Needs https://github.com/ChilliCream/graphql-platform/issues/8313
- ;
+ && restResult.CreatedBy.Name == gqlUser.CreatedBy.Name;
},
cancellationToken);
@@ -270,9 +269,8 @@ namespace Tgstation.Server.Tests.Live
// Assert.AreEqual(Math.Min(ApiController.DefaultPageSize, users.TotalCount), users.Nodes.Count);
Assert.IsTrue(Math.Min(ApiController.DefaultPageSize, users.TotalCount) >= users.Nodes.Count);
- // Needs https://github.com/ChilliCream/graphql-platform/issues/8313
- // var tgsUserResult2 = await client.RunOperation(gql => gql.GetUserById.ExecuteAsync(gqlUser.Swarm.Users.Current.CreatedBy.Id, cancellationToken), cancellationToken);
- // Assert.IsTrue(tgsUserResult2.IsErrorResult());
+ var tgsUserResult2 = await client.RunOperation(gql => gql.GetUserById.ExecuteAsync(gqlUser.Swarm.Users.Current.CreatedBy.Id, cancellationToken), cancellationToken);
+ Assert.IsTrue(tgsUserResult2.IsErrorResult());
var sampleOAuthConnections = new List
{