Activating more style analyzers

This commit is contained in:
Jordan Dominion
2023-07-03 22:36:26 -04:00
parent d5380c5cb9
commit fa50b61b8f
46 changed files with 197 additions and 111 deletions
+2
View File
@@ -2,9 +2,11 @@
<Import Project="Common.props" />
<PropertyGroup>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<CodeAnalysisRuleSet>../../build/analyzers.ruleset</CodeAnalysisRuleSet>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DocumentationFile>bin/$(Configuration)/$(TargetFramework)/$(AssemblyName).xml</DocumentationFile>
<NodeModulesFolder>ClientApp/node_modules</NodeModulesFolder>
<NpmInstallStampFile>ClientApp/node_modules/.install-stamp</NpmInstallStampFile>
+3 -3
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="myrules" Description="My rule set" ToolsVersion="16.0">
<RuleSet Name="myrules" Description="My rule set" ToolsVersion="17.0">
<Rules AnalyzerId="AsyncUsageAnalyzers" RuleNamespace="AsyncUsageAnalyzers">
<Rule Id="UseConfigureAwait" Action="Warning" />
</Rules>
@@ -1026,8 +1026,8 @@
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1118" Action="None" />
<Rule Id="SA1121" Action="None" />
<Rule Id="SA1127" Action="None" />
<Rule Id="SA1128" Action="None" />
<Rule Id="SA1127" Action="Warning" />
<Rule Id="SA1128" Action="Warning" />
<Rule Id="SA1201" Action="None" />
<Rule Id="SA1400" Action="None" />
<Rule Id="SA1412" Action="Warning" />
+8
View File
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"documentPrivateElements": true,
@@ -33,6 +34,13 @@
"accessibility"
],
"usingDirectivesPlacement": "outsideNamespace"
},
"namingRules": {
"allowCommonHungarianPrefixes": false,
"includeInferredTupleElementNames": true
},
"readabilityRules": {
"allowBuiltInTypeAliases": true
}
}
}
+4 -2
View File
@@ -124,7 +124,8 @@ namespace Tgstation.Server.Api
/// <param name="userAgent">The value of <see cref="UserAgent"/>.</param>
/// <param name="token">The value of <see cref="Token"/>.</param>
/// <param name="oauthProvider">The value of <see cref="OAuthProvider"/>.</param>
public ApiHeaders(ProductHeaderValue userAgent, string token, OAuthProvider? oauthProvider = null) : this(userAgent, token, null, null)
public ApiHeaders(ProductHeaderValue userAgent, string token, OAuthProvider? oauthProvider = null)
: this(userAgent, token, null, null)
{
if (userAgent == null)
throw new ArgumentNullException(nameof(userAgent));
@@ -140,7 +141,8 @@ namespace Tgstation.Server.Api
/// <param name="userAgent">The value of <see cref="UserAgent"/>.</param>
/// <param name="username">The value of <see cref="Username"/>.</param>
/// <param name="password">The value of <see cref="Password"/>.</param>
public ApiHeaders(ProductHeaderValue userAgent, string username, string password) : this(userAgent, null, username, password)
public ApiHeaders(ProductHeaderValue userAgent, string username, string password)
: this(userAgent, null, username, password)
{
if (userAgent == null)
throw new ArgumentNullException(nameof(userAgent));
+6 -3
View File
@@ -17,7 +17,8 @@ namespace Tgstation.Server.Api
/// </summary>
/// <param name="missingOrMalformedHeaders">The value of <see cref="MissingOrMalformedHeaders"/>.</param>
/// <param name="message">The error message.</param>
public HeadersException(HeaderTypes missingOrMalformedHeaders, string message) : base(message)
public HeadersException(HeaderTypes missingOrMalformedHeaders, string message)
: base(message)
{
MissingOrMalformedHeaders = missingOrMalformedHeaders;
}
@@ -33,7 +34,8 @@ namespace Tgstation.Server.Api
/// Initializes a new instance of the <see cref="HeadersException"/> class.
/// </summary>
/// <param name="message">The error message.</param>
public HeadersException(string message) : base(message)
public HeadersException(string message)
: base(message)
{
}
@@ -42,7 +44,8 @@ namespace Tgstation.Server.Api
/// </summary>
/// <param name="message">The error message.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public HeadersException(string message, Exception innerException) : base(message, innerException)
public HeadersException(string message, Exception innerException)
: base(message, innerException)
{
}
}
+2 -1
View File
@@ -24,7 +24,8 @@
/// </summary>
/// <typeparam name="TResultType">The child of <see cref="UserName"/> to create.</typeparam>
/// <returns>A new <typeparamref name="TResultType"/> copied from <see langword="this"/>.</returns>
protected virtual TResultType CreateUserName<TResultType>() where TResultType : UserName, new() => new TResultType
protected virtual TResultType CreateUserName<TResultType>()
where TResultType : UserName, new() => new TResultType
{
Id = Id,
Name = Name,
@@ -38,7 +38,8 @@ namespace Tgstation.Server.Api.Rights
/// <typeparam name="TRight">The <see cref="RightsType"/>.</typeparam>
/// <param name="right">The <typeparamref name="TRight"/>.</param>
/// <returns>A <see cref="string"/> representing the claim role name.</returns>
public static string RoleNames<TRight>(TRight right) where TRight : Enum
public static string RoleNames<TRight>(TRight right)
where TRight : Enum
{
IEnumerable<string> GetRoleNames()
{
@@ -75,7 +76,8 @@ namespace Tgstation.Server.Api.Rights
/// </summary>
/// <typeparam name="TRight">The <see cref="RightsType"/>.</typeparam>
/// <returns>All rights for the given <typeparamref name="TRight"/>.</returns>
public static TRight AllRights<TRight>() where TRight : Enum
public static TRight AllRights<TRight>()
where TRight : Enum
{
ulong rights = 0;
foreach (Enum right in Enum.GetValues(typeof(TRight)))
@@ -91,7 +93,8 @@ namespace Tgstation.Server.Api.Rights
/// <typeparam name="TRight">The <see cref="RightsType"/>.</typeparam>
/// <param name="rights">The <typeparamref name="TRight"/>s to clamp.</param>
/// <returns>The clamped <paramref name="rights"/>.</returns>
public static TRight Clamp<TRight>(TRight rights) where TRight : Enum
public static TRight Clamp<TRight>(TRight rights)
where TRight : Enum
{
var allRights = AllRights<TRight>();
+39 -16
View File
@@ -168,55 +168,78 @@ namespace Tgstation.Server.Client
}
/// <inheritdoc />
public Task<TResult> Create<TResult>(string route, CancellationToken cancellationToken) => RunRequest<object, TResult>(route, new object(), HttpMethod.Put, null, false, cancellationToken);
public Task<TResult> Create<TResult>(string route, CancellationToken cancellationToken)
=> RunRequest<object, TResult>(route, new object(), HttpMethod.Put, null, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Read<TResult>(string route, CancellationToken cancellationToken) => RunRequest<object, TResult>(route, null, HttpMethod.Get, null, false, cancellationToken);
public Task<TResult> Read<TResult>(string route, CancellationToken cancellationToken)
=> RunRequest<object, TResult>(route, null, HttpMethod.Get, null, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Update<TResult>(string route, CancellationToken cancellationToken) => RunRequest<object, TResult>(route, new object(), HttpMethod.Post, null, false, cancellationToken);
public Task<TResult> Update<TResult>(string route, CancellationToken cancellationToken)
=> RunRequest<object, TResult>(route, new object(), HttpMethod.Post, null, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Update<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, TResult>(route, body, HttpMethod.Post, null, false, cancellationToken);
public Task<TResult> Update<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, TResult>(route, body, HttpMethod.Post, null, false, cancellationToken);
/// <inheritdoc />
public Task Patch(string route, CancellationToken cancellationToken) => RunRequest<object>(route, null, HttpPatch, null, false, cancellationToken);
/// <inheritdoc />
public Task Update<TBody>(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, object>(route, body, HttpMethod.Post, null, false, cancellationToken);
public Task Update<TBody>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, object>(route, body, HttpMethod.Post, null, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Create<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, TResult>(route, body, HttpMethod.Put, null, false, cancellationToken);
public Task<TResult> Create<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, TResult>(route, body, HttpMethod.Put, null, false, cancellationToken);
/// <inheritdoc />
public Task Delete(string route, CancellationToken cancellationToken) => RunRequest<object>(route, null, HttpMethod.Delete, null, false, cancellationToken);
public Task Delete(string route, CancellationToken cancellationToken)
=> RunRequest<object>(route, null, HttpMethod.Delete, null, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Create<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, TResult>(route, body, HttpMethod.Put, instanceId, false, cancellationToken);
public Task<TResult> Create<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, TResult>(route, body, HttpMethod.Put, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Read<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<TResult>(route, null, HttpMethod.Get, instanceId, false, cancellationToken);
public Task<TResult> Read<TResult>(string route, long instanceId, CancellationToken cancellationToken)
=> RunRequest<TResult>(route, null, HttpMethod.Get, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Update<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, TResult>(route, body, HttpMethod.Post, instanceId, false, cancellationToken);
public Task<TResult> Update<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, TResult>(route, body, HttpMethod.Post, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task Delete(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<object>(route, null, HttpMethod.Delete, instanceId, false, cancellationToken);
public Task Delete(string route, long instanceId, CancellationToken cancellationToken)
=> RunRequest<object>(route, null, HttpMethod.Delete, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task Delete<TBody>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, object>(route, body, HttpMethod.Delete, instanceId, false, cancellationToken);
public Task Delete<TBody>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, object>(route, body, HttpMethod.Delete, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Delete<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<TResult>(route, null, HttpMethod.Delete, instanceId, false, cancellationToken);
public Task<TResult> Delete<TResult>(string route, long instanceId, CancellationToken cancellationToken)
=> RunRequest<TResult>(route, null, HttpMethod.Delete, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Delete<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class => RunRequest<TBody, TResult>(route, body, HttpMethod.Delete, instanceId, false, cancellationToken);
public Task<TResult> Delete<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class
=> RunRequest<TBody, TResult>(route, body, HttpMethod.Delete, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Create<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<object, TResult>(route, new object(), HttpMethod.Put, instanceId, false, cancellationToken);
public Task<TResult> Create<TResult>(string route, long instanceId, CancellationToken cancellationToken)
=> RunRequest<object, TResult>(route, new object(), HttpMethod.Put, instanceId, false, cancellationToken);
/// <inheritdoc />
public Task<TResult> Patch<TResult>(string route, long instanceId, CancellationToken cancellationToken) => RunRequest<object, TResult>(route, new object(), HttpPatch, instanceId, false, cancellationToken);
public Task<TResult> Patch<TResult>(string route, long instanceId, CancellationToken cancellationToken)
=> RunRequest<object, TResult>(route, new object(), HttpPatch, instanceId, false, cancellationToken);
/// <inheritdoc />
public void AddRequestLogger(IRequestLogger requestLogger) => requestLoggers.Add(requestLogger ?? throw new ArgumentNullException(nameof(requestLogger)));
@@ -15,7 +15,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public ApiConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public ApiConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ApiConflictException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public ApiConflictException(string message) : base(message)
public ApiConflictException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public ApiConflictException(string message, Exception innerException) : base(message, innerException)
public ApiConflictException(string message, Exception innerException)
: base(message, innerException)
{
}
}
+10 -8
View File
@@ -31,9 +31,10 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> returned from the API.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/>.</param>
protected ApiException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(
responseMessage,
errorMessage?.Message ?? $"HTTP {responseMessage?.StatusCode ?? throw new ArgumentNullException(nameof(responseMessage))}. Unknown API error, ErrorMessage payload not present!")
protected ApiException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(
responseMessage,
errorMessage?.Message ?? $"HTTP {responseMessage?.StatusCode ?? throw new ArgumentNullException(nameof(responseMessage))}. Unknown API error, ErrorMessage payload not present!")
{
ServerApiVersion = errorMessage?.ServerApiVersion;
AdditionalServerData = errorMessage?.AdditionalData;
@@ -45,9 +46,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/>.</param>
/// <param name="message">The <see cref="Exception.Message"/>.</param>
protected ApiException(HttpResponseMessage responseMessage, string message) : base(
responseMessage,
message)
protected ApiException(HttpResponseMessage responseMessage, string message)
: base(responseMessage, message)
{
}
@@ -62,7 +62,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
protected ApiException(string message) : base(message)
protected ApiException(string message)
: base(message)
{
}
@@ -71,7 +72,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
protected ApiException(string message, Exception innerException) : base(message, innerException)
protected ApiException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -19,7 +19,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> that generated the <see cref="ClientException"/>.</param>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
protected ClientException(HttpResponseMessage responseMessage, string message) : base(message)
protected ClientException(HttpResponseMessage responseMessage, string message)
: base(message)
{
ResponseMessage = responseMessage ?? throw new ArgumentNullException(nameof(responseMessage));
}
@@ -35,7 +36,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ClientException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
protected ClientException(string message) : base(message)
protected ClientException(string message)
: base(message)
{
}
@@ -44,7 +46,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
protected ClientException(string message, Exception innerException) : base(message, innerException)
protected ClientException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -15,7 +15,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public ConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public ConflictException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ConflictException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public ConflictException(string message) : base(message)
public ConflictException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public ConflictException(string message, Exception innerException) : base(message, innerException)
public ConflictException(string message, Exception innerException)
: base(message, innerException)
{
}
}
+10 -5
View File
@@ -44,7 +44,8 @@ namespace Tgstation.Server.Client
/// <param name="body">The request body.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the response body as a <typeparamref name="TResult"/>.</returns>
Task<TResult> Create<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken) where TBody : class;
Task<TResult> Create<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class;
/// <summary>
/// Run an HTTP PUT request.
@@ -73,7 +74,8 @@ namespace Tgstation.Server.Client
/// <param name="body">The request body.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task{TResult}"/> resulting in the response body as a <typeparamref name="TResult"/>.</returns>
Task<TResult> Update<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken) where TBody : class;
Task<TResult> Update<TBody, TResult>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class;
/// <summary>
/// Run an HTTP POST request.
@@ -92,7 +94,8 @@ namespace Tgstation.Server.Client
/// <param name="body">The request body.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
Task Update<TBody>(string route, TBody body, CancellationToken cancellationToken) where TBody : class;
Task Update<TBody>(string route, TBody body, CancellationToken cancellationToken)
where TBody : class;
/// <summary>
/// Run an HTTP PATCH request.
@@ -192,7 +195,8 @@ namespace Tgstation.Server.Client
/// <param name="instanceId">The instance <see cref="EntityId.Id"/> to make the request to.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
Task Delete<TBody>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class;
Task Delete<TBody>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class;
/// <summary>
/// Run an HTTP DELETE request.
@@ -214,7 +218,8 @@ namespace Tgstation.Server.Client
/// <param name="instanceId">The instance <see cref="EntityId.Id"/> to make the request to.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="Task"/> representing the running operation.</returns>
Task<TResult> Delete<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken) where TBody : class;
Task<TResult> Delete<TBody, TResult>(string route, TBody body, long instanceId, CancellationToken cancellationToken)
where TBody : class;
/// <summary>
/// Downloads a file <see cref="Stream"/> for a given <paramref name="ticket"/>.
@@ -12,9 +12,10 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="InsufficientPermissionsException"/> class.
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public InsufficientPermissionsException(HttpResponseMessage responseMessage) : base(
responseMessage,
"The current user has insufficient permissions to perform the requested operation!")
public InsufficientPermissionsException(HttpResponseMessage responseMessage)
: base(
responseMessage,
"The current user has insufficient permissions to perform the requested operation!")
{
}
@@ -29,7 +30,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="InsufficientPermissionsException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public InsufficientPermissionsException(string message) : base(message)
public InsufficientPermissionsException(string message)
: base(message)
{
}
@@ -38,7 +40,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public InsufficientPermissionsException(string message, Exception innerException) : base(message, innerException)
public InsufficientPermissionsException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -15,7 +15,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public MethodNotSupportedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public MethodNotSupportedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="MethodNotSupportedException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public MethodNotSupportedException(string message) : base(message)
public MethodNotSupportedException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public MethodNotSupportedException(string message, Exception innerException) : base(message, innerException)
public MethodNotSupportedException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -23,7 +23,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public RateLimitException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
if (responseMessage == null)
throw new ArgumentNullException(nameof(responseMessage));
@@ -47,7 +48,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="RateLimitException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public RateLimitException(string message) : base(message)
public RateLimitException(string message)
: base(message)
{
}
@@ -56,7 +58,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public RateLimitException(string message, Exception innerException) : base(message, innerException)
public RateLimitException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -12,7 +12,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="RequestTimeoutException"/> class.
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public RequestTimeoutException(HttpResponseMessage responseMessage) : base(responseMessage, "The request timed out!")
public RequestTimeoutException(HttpResponseMessage responseMessage)
: base(responseMessage, "The request timed out!")
{
}
@@ -27,7 +28,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="RequestTimeoutException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public RequestTimeoutException(string message) : base(message)
public RequestTimeoutException(string message)
: base(message)
{
}
@@ -36,7 +38,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public RequestTimeoutException(string message, Exception innerException) : base(message, innerException)
public RequestTimeoutException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -22,7 +22,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public ServerErrorException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public ServerErrorException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ServerErrorException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public ServerErrorException(string message) : base(message)
public ServerErrorException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public ServerErrorException(string message, Exception innerException) : base(message, innerException)
public ServerErrorException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -12,7 +12,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ServiceUnavailableException"/> class.
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/>.</param>
public ServiceUnavailableException(HttpResponseMessage responseMessage) : base(responseMessage, "The service is unavailable!")
public ServiceUnavailableException(HttpResponseMessage responseMessage)
: base(responseMessage, "The service is unavailable!")
{
}
@@ -27,7 +28,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="ServiceUnavailableException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public ServiceUnavailableException(string message) : base(message)
public ServiceUnavailableException(string message)
: base(message)
{
}
@@ -36,7 +38,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public ServiceUnavailableException(string message, Exception innerException) : base(message, innerException)
public ServiceUnavailableException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -15,7 +15,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> returned by the API.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/>.</param>
public UnauthorizedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public UnauthorizedException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="UnauthorizedException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public UnauthorizedException(string message) : base(message)
public UnauthorizedException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public UnauthorizedException(string message, Exception innerException) : base(message, innerException)
public UnauthorizedException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -12,7 +12,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="UnrecognizedResponseException"/> class.
/// </summary>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/>.</param>
public UnrecognizedResponseException(HttpResponseMessage responseMessage) : base(responseMessage, "Unrecognized response body!")
public UnrecognizedResponseException(HttpResponseMessage responseMessage)
: base(responseMessage, "Unrecognized response body!")
{
}
@@ -27,7 +28,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="UnrecognizedResponseException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public UnrecognizedResponseException(string message) : base(message)
public UnrecognizedResponseException(string message)
: base(message)
{
}
@@ -36,7 +38,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public UnrecognizedResponseException(string message, Exception innerException) : base(message, innerException)
public UnrecognizedResponseException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -15,7 +15,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="errorMessage">The <see cref="ErrorMessageResponse"/> for the <see cref="ApiException"/>.</param>
/// <param name="responseMessage">The <see cref="HttpResponseMessage"/> for the <see cref="ClientException"/>.</param>
public VersionMismatchException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage) : base(errorMessage, responseMessage)
public VersionMismatchException(ErrorMessageResponse? errorMessage, HttpResponseMessage responseMessage)
: base(errorMessage, responseMessage)
{
}
@@ -30,7 +31,8 @@ namespace Tgstation.Server.Client
/// Initializes a new instance of the <see cref="VersionMismatchException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public VersionMismatchException(string message) : base(message)
public VersionMismatchException(string message)
: base(message)
{
}
@@ -39,7 +41,8 @@ namespace Tgstation.Server.Client
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the base <see cref="Exception"/>.</param>
public VersionMismatchException(string message, Exception innerException) : base(message, innerException)
public VersionMismatchException(string message, Exception innerException)
: base(message, innerException)
{
}
}
@@ -11,7 +11,6 @@ using Microsoft.Extensions.Logging;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Host.Components.Events;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Jobs;
using Tgstation.Server.Host.Utils;
@@ -14,7 +14,6 @@ using Tgstation.Server.Host.Components.Chat.Commands;
using Tgstation.Server.Host.Components.Chat.Providers;
using Tgstation.Server.Host.Components.Interop;
using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.Utils;
namespace Tgstation.Server.Host.Components.Chat
@@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging;
using Tgstation.Server.Api.Rights;
using Tgstation.Server.Host.Components.Interop;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.Jobs;
using Tgstation.Server.Host.Models;
using Tgstation.Server.Host.Utils;
@@ -18,7 +18,6 @@ using Tgstation.Server.Host.Components.Repository;
using Tgstation.Server.Host.Components.Session;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Database;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Jobs;
using Tgstation.Server.Host.Models;
@@ -37,7 +37,8 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge
/// </summary>
/// <param name="testMerge">The <see cref="Models.TestMerge"/> to build from.</param>
/// <param name="revision">The value of <see cref="Revision"/>.</param>
public TestMergeInformation(Models.TestMerge testMerge, RevisionInformation revision) : base(testMerge)
public TestMergeInformation(Models.TestMerge testMerge, RevisionInformation revision)
: base(testMerge)
{
TimeMerged = testMerge?.MergedAt.Ticks.ToString(CultureInfo.InvariantCulture) ?? throw new ArgumentNullException(nameof(testMerge));
Revision = revision ?? throw new ArgumentNullException(nameof(revision));
@@ -7,7 +7,6 @@ using Microsoft.Extensions.Logging;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Internal;
using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.Components.Repository
{
@@ -48,7 +48,8 @@ namespace Tgstation.Server.Host.Components.Session
Models.ReattachInformation copy,
IDmbProvider dmb,
IDmbProvider initialDmb,
TimeSpan topicRequestTimeout) : base(copy)
TimeSpan topicRequestTimeout)
: base(copy)
{
Dmb = dmb ?? throw new ArgumentNullException(nameof(dmb));
InitialDmb = initialDmb;
@@ -284,7 +284,8 @@ namespace Tgstation.Server.Host.Core
services.AddHttpClient();
services.AddSingleton<IAbstractHttpClientFactory, AbstractHttpClientFactory>();
void AddTypedContext<TContext>() where TContext : DatabaseContext
void AddTypedContext<TContext>()
where TContext : DatabaseContext
{
var configureAction = DatabaseContext.GetConfigureAction<TContext>();
@@ -10,7 +10,6 @@ using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Common;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.Core
{
@@ -10,7 +10,8 @@ using Microsoft.EntityFrameworkCore;
namespace Tgstation.Server.Host.Database
{
/// <inheritdoc />
sealed class DatabaseCollection<TModel> : IDatabaseCollection<TModel> where TModel : class
sealed class DatabaseCollection<TModel> : IDatabaseCollection<TModel>
where TModel : class
{
/// <summary>
/// The backing <see cref="DbSet{TEntity}"/>.
@@ -255,7 +255,8 @@ namespace Tgstation.Server.Host.Database
/// Initializes a new instance of the <see cref="DatabaseContext"/> class.
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions"/> for the <see cref="DatabaseContext"/>.</param>
protected DatabaseContext(DbContextOptions dbContextOptions) : base(dbContextOptions)
protected DatabaseContext(DbContextOptions dbContextOptions)
: base(dbContextOptions)
{
usersCollection = new DatabaseCollection<User>(Users);
instancesCollection = new DatabaseCollection<Instance>(Instances);
@@ -22,7 +22,8 @@ namespace Tgstation.Server.Host.Database
/// Initializes a new instance of the <see cref="MySqlDatabaseContext"/> class.
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/>.</param>
public MySqlDatabaseContext(DbContextOptions<MySqlDatabaseContext> dbContextOptions) : base(dbContextOptions)
public MySqlDatabaseContext(DbContextOptions<MySqlDatabaseContext> dbContextOptions)
: base(dbContextOptions)
{
}
@@ -16,7 +16,8 @@ namespace Tgstation.Server.Host.Database
/// Initializes a new instance of the <see cref="SqlServerDatabaseContext"/> class.
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/>.</param>
public SqlServerDatabaseContext(DbContextOptions<SqlServerDatabaseContext> dbContextOptions) : base(dbContextOptions)
public SqlServerDatabaseContext(DbContextOptions<SqlServerDatabaseContext> dbContextOptions)
: base(dbContextOptions)
{
}
@@ -56,7 +56,8 @@ namespace Tgstation.Server.Host.Extensions
/// Change the <see cref="Type"/> used as an implementation for calls to <see cref="AddChatProviderFactory(IServiceCollection)"/>.
/// </summary>
/// <typeparam name="TProviderFactory">The <see cref="IProviderFactory"/> implementation to use.</typeparam>
public static void UseChatProviderFactory<TProviderFactory>() where TProviderFactory : IProviderFactory
public static void UseChatProviderFactory<TProviderFactory>()
where TProviderFactory : IProviderFactory
{
chatProviderFactoryType = typeof(TProviderFactory);
}
@@ -65,7 +66,8 @@ namespace Tgstation.Server.Host.Extensions
/// Change the <see cref="Type"/> used as an implementation for calls to <see cref="AddGitHub(IServiceCollection)"/>.
/// </summary>
/// <typeparam name="TGitHubServiceFactory">The <see cref="IGitHubServiceFactory"/> implementation to use.</typeparam>
public static void UseGitHubServiceFactory<TGitHubServiceFactory>() where TGitHubServiceFactory : IGitHubServiceFactory
public static void UseGitHubServiceFactory<TGitHubServiceFactory>()
where TGitHubServiceFactory : IGitHubServiceFactory
{
gitHubServiceFactoryType = typeof(TGitHubServiceFactory);
}
@@ -74,7 +76,8 @@ namespace Tgstation.Server.Host.Extensions
/// Change the <see cref="Type"/> used as an implementation for calls to <see cref="AddGitHub(IServiceCollection)"/>.
/// </summary>
/// <typeparam name="TFileDownloader">The <see cref="IFileDownloader"/> implementation to use.</typeparam>
public static void UseFileDownloader<TFileDownloader>() where TFileDownloader : IFileDownloader
public static void UseFileDownloader<TFileDownloader>()
where TFileDownloader : IFileDownloader
{
fileDownloaderType = typeof(TFileDownloader);
}
@@ -112,7 +115,8 @@ namespace Tgstation.Server.Host.Extensions
/// Add an additional <see cref="ILoggerProvider"/> to <see cref="IServiceCollection"/>s that call <see cref="SetupLogging(IServiceCollection, Action{LoggerConfiguration}, Action{LoggerSinkConfiguration}, ElasticsearchSinkOptions, InternalConfiguration, FileLoggingConfiguration)"/>.
/// </summary>
/// <typeparam name="TLoggerProvider">The <see cref="Type"/> of <see cref="ILoggerProvider"/> to add.</typeparam>
public static void UseAdditionalLoggerProvider<TLoggerProvider>() where TLoggerProvider : class, ILoggerProvider
public static void UseAdditionalLoggerProvider<TLoggerProvider>()
where TLoggerProvider : class, ILoggerProvider
{
if (additionalLoggerProvider != null)
throw new InvalidOperationException("Cannot have multiple additionalLoggerProviders!");
@@ -138,7 +142,8 @@ namespace Tgstation.Server.Host.Extensions
/// <param name="serviceCollection">The <see cref="IServiceCollection"/> to configure.</param>
/// <param name="configuration">The <see cref="IConfiguration"/> containing the <typeparamref name="TConfig"/>.</param>
/// <returns><paramref name="serviceCollection"/>.</returns>
public static IServiceCollection UseStandardConfig<TConfig>(this IServiceCollection serviceCollection, IConfiguration configuration) where TConfig : class
public static IServiceCollection UseStandardConfig<TConfig>(this IServiceCollection serviceCollection, IConfiguration configuration)
where TConfig : class
{
ArgumentNullException.ThrowIfNull(serviceCollection);
ArgumentNullException.ThrowIfNull(configuration);
@@ -6,7 +6,6 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.Utils;
namespace Tgstation.Server.Host.IO
@@ -25,7 +25,8 @@ namespace Tgstation.Server.Host.Jobs
/// Initializes a new instance of the <see cref="JobException"/> class.
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
public JobException(string message) : base(message)
public JobException(string message)
: base(message)
{
}
@@ -34,7 +35,8 @@ namespace Tgstation.Server.Host.Jobs
/// </summary>
/// <param name="message">The message for the <see cref="Exception"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the nase <see cref="Exception"/>.</param>
public JobException(string message, Exception innerException) : base(message, innerException)
public JobException(string message, Exception innerException)
: base(message, innerException)
{
}
@@ -42,7 +44,8 @@ namespace Tgstation.Server.Host.Jobs
/// Initializes a new instance of the <see cref="JobException"/> class.
/// </summary>
/// <param name="errorCode">The associated <see cref="Api.Models.ErrorCode"/>.</param>
public JobException(ErrorCode errorCode) : base(errorCode.Describe())
public JobException(ErrorCode errorCode)
: base(errorCode.Describe())
{
ErrorCode = errorCode;
}
@@ -52,7 +55,8 @@ namespace Tgstation.Server.Host.Jobs
/// </summary>
/// <param name="errorCode">The associated <see cref="Api.Models.ErrorCode"/>.</param>
/// <param name="innerException">The inner <see cref="Exception"/> for the nase <see cref="Exception"/>.</param>
public JobException(ErrorCode errorCode, Exception innerException) : base(errorCode.Describe(), innerException)
public JobException(ErrorCode errorCode, Exception innerException)
: base(errorCode.Describe(), innerException)
{
ErrorCode = errorCode;
}
@@ -2,8 +2,6 @@
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.Jobs
{
/// <summary>
@@ -69,7 +69,7 @@ namespace Tgstation.Server.Host.Security
var prop = typeToCheck.GetProperties().Where(x => x.PropertyType == nullableRightsType).First();
var right = prop.GetMethod.Invoke(isInstance ? (object)InstancePermissionSet : PermissionSet, Array.Empty<object>());
var right = prop.GetMethod.Invoke(isInstance ? InstancePermissionSet : PermissionSet, Array.Empty<object>());
if (right == null)
throw new InvalidOperationException("A user right was null!");
@@ -4,7 +4,6 @@ using System.Reflection;
using Tgstation.Server.Common;
using Tgstation.Server.Common.Extensions;
using Tgstation.Server.Host.Common;
namespace Tgstation.Server.Host.System
{
@@ -6,7 +6,6 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
namespace Tgstation.Server.Host.System
@@ -10,7 +10,6 @@ using Mono.Unix;
using Tgstation.Server.Host.Components;
using Tgstation.Server.Host.Core;
using Tgstation.Server.Host.Extensions;
namespace Tgstation.Server.Host.System
{
@@ -8,7 +8,6 @@ using Microsoft.Extensions.Logging;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Security;
using Tgstation.Server.Host.Utils;
@@ -7,7 +7,6 @@ using Microsoft.AspNetCore.WebUtilities;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Models.Response;
using Tgstation.Server.Host.Extensions;
using Tgstation.Server.Host.IO;
namespace Tgstation.Server.Host.Transfer
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;