diff --git a/src/Tgstation.Server.Host/Authority/Core/GraphQLAuthorityInvoker{TAuthority}.cs b/src/Tgstation.Server.Host/Authority/Core/GraphQLAuthorityInvoker{TAuthority}.cs index e5eacacafa..35cc1cbcd1 100644 --- a/src/Tgstation.Server.Host/Authority/Core/GraphQLAuthorityInvoker{TAuthority}.cs +++ b/src/Tgstation.Server.Host/Authority/Core/GraphQLAuthorityInvoker{TAuthority}.cs @@ -85,7 +85,7 @@ namespace Tgstation.Server.Host.Authority.Core if (result == null) return default; - var transformedResult = new TTransformer().CompiledExpression(result); + var transformedResult = new TTransformer().Transform(result); return transformedResult; } diff --git a/src/Tgstation.Server.Host/Authority/Core/RestAuthorityInvoker{TAuthority}.cs b/src/Tgstation.Server.Host/Authority/Core/RestAuthorityInvoker{TAuthority}.cs index 70c52deede..4abe922cee 100644 --- a/src/Tgstation.Server.Host/Authority/Core/RestAuthorityInvoker{TAuthority}.cs +++ b/src/Tgstation.Server.Host/Authority/Core/RestAuthorityInvoker{TAuthority}.cs @@ -144,7 +144,7 @@ namespace Tgstation.Server.Host.Authority.Core if (erroredResult != null) return erroredResult; - return CreateSuccessfulActionResult(controller, result => new TTransformer().CompiledExpression(result), authorityResponse!); + return CreateSuccessfulActionResult(controller, result => new TTransformer().Transform(result), authorityResponse!); } /// diff --git a/src/Tgstation.Server.Host/Authority/UserAuthority.cs b/src/Tgstation.Server.Host/Authority/UserAuthority.cs index 6830de8f81..18eacc5f71 100644 --- a/src/Tgstation.Server.Host/Authority/UserAuthority.cs +++ b/src/Tgstation.Server.Host/Authority/UserAuthority.cs @@ -611,7 +611,7 @@ namespace Tgstation.Server.Host.Authority ValueTask SendUserUpdatedTopics(User user) { var transformed = new GraphQL.Transformers.UserTransformer() - .CompiledExpression(user); + .Transform(user); return ValueTaskExtensions.WhenAll( GraphQL.Subscriptions.UserSubscriptions.UserUpdatedTopics( user.Require(x => x.Id)) diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index d5030fa3f1..423da58acb 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -281,7 +281,7 @@ namespace Tgstation.Server.Host.Controllers var transformer = new TTransformer(); return PaginatedImpl( queryGenerator, - model => transformer.CompiledExpression(model), + transformer.Transform, null, pageQuery, pageSizeQuery, diff --git a/src/Tgstation.Server.Host/Models/ITransformer{TInput,TOutput}.cs b/src/Tgstation.Server.Host/Models/ITransformer{TInput,TOutput}.cs index a845c8e78d..cfff208ebf 100644 --- a/src/Tgstation.Server.Host/Models/ITransformer{TInput,TOutput}.cs +++ b/src/Tgstation.Server.Host/Models/ITransformer{TInput,TOutput}.cs @@ -23,8 +23,10 @@ namespace Tgstation.Server.Host.Models Expression>> ProjectedExpression { get; } /// - /// The compiled . + /// The compiled transformation . /// - Func CompiledExpression { get; } + /// The input . + /// The transformed . + TOutput Transform(TInput input); } } diff --git a/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs b/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs index 7eb4f1506b..1da0c09d9e 100644 --- a/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs +++ b/src/Tgstation.Server.Host/Models/TransformerBase{TInput,TOutput}.cs @@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Models abstract class TransformerBase : ITransformer { /// - /// cache for . + /// cache for compiling the we were constructed with. /// static Func? compiledExpression; // This is safe https://stackoverflow.com/a/9647661/3976486 @@ -25,9 +25,6 @@ namespace Tgstation.Server.Host.Models /// public Expression>> ProjectedExpression { get; } - /// - public Func CompiledExpression { get; } - /// /// Gets the that should be used when a database projected non-null DTO value is null in the expression. /// @@ -188,8 +185,11 @@ namespace Tgstation.Server.Host.Models compiledExpression ??= expression.Compile(); projectedExpression ??= expression.Projected(); Expression = expression; - CompiledExpression = compiledExpression; ProjectedExpression = projectedExpression; } + + /// + public TOutput Transform(TInput input) + => compiledExpression!(input); } }