Final Rider inspections

This commit is contained in:
Archi
2022-12-15 19:23:46 +01:00
parent c9cae6e258
commit fc20b6cfc4
12 changed files with 35 additions and 22 deletions

View File

@@ -75,7 +75,7 @@ public sealed class TypeController : ArchiController {
}
}
foreach (PropertyInfo property in targetType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(static property => property.CanRead && (property.GetMethod?.IsPrivate == false))) {
foreach (PropertyInfo property in targetType.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).Where(static property => property is { CanRead: true, GetMethod.IsPrivate: false })) {
JsonPropertyAttribute? jsonProperty = property.GetCustomAttribute<JsonPropertyAttribute>();
if (jsonProperty != null) {

View File

@@ -101,7 +101,7 @@ internal sealed class Startup {
app.UseStaticFiles(
new StaticFileOptions {
OnPrepareResponse = static context => {
if (context.File.Exists && !context.File.IsDirectory && !string.IsNullOrEmpty(context.File.Name)) {
if (context.File is { Exists: true, IsDirectory: false } && !string.IsNullOrEmpty(context.File.Name)) {
string extension = Path.GetExtension(context.File.Name);
CacheControlHeaderValue cacheControl = new();

View File

@@ -93,11 +93,15 @@ internal static class WebUtilities {
StreamWriter streamWriter = new(response.Body, Encoding.UTF8);
await using (streamWriter.ConfigureAwait(false)) {
using JsonTextWriter jsonWriter = new(streamWriter) {
#pragma warning disable CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
JsonTextWriter jsonWriter = new(streamWriter) {
CloseOutput = false
};
#pragma warning restore CA2000 // False positive, we're actually wrapping it in the using clause below exactly for that purpose
serializer.Serialize(jsonWriter, value);
await using (jsonWriter.ConfigureAwait(false)) {
serializer.Serialize(jsonWriter, value);
}
}
}
}