Skip to content

Commit 531bf49

Browse files
committed
Fix warnings
1 parent ae163c5 commit 531bf49

File tree

13 files changed

+24
-34
lines changed

13 files changed

+24
-34
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ indent_style = tab
7575

7676
[*.{cs,csx,cake,vb,vbx}]
7777
# Default Severity for all .NET Code Style rules below
78-
dotnet_analyzer_diagnostic.severity = warning
78+
dotnet_analyzer_diagnostic.category-style.severity = warning
7979

8080
##########################################
8181
# Language Rules

src/ImageSharp.Web/Caching/CacheHash.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Security.Cryptography;
88
using System.Text;
99
using Microsoft.Extensions.Options;
10-
using SixLabors.ImageSharp.Memory;
1110
using SixLabors.ImageSharp.Web.Middleware;
1211

1312
namespace SixLabors.ImageSharp.Web.Caching

src/ImageSharp.Web/Caching/ICacheHash.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
namespace SixLabors.ImageSharp.Web.Caching
@@ -16,4 +16,4 @@ public interface ICacheHash
1616
/// <returns>The <see cref="string"/>.</returns>
1717
string Create(string value, uint length);
1818
}
19-
}
19+
}

src/ImageSharp.Web/Commands/DictionaryExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Collections.Generic;
@@ -24,4 +24,4 @@ public static TValue GetValueOrDefault<TValue, TKey>(this IDictionary<TKey, TVal
2424
return result;
2525
}
2626
}
27-
}
27+
}

src/ImageSharp.Web/Commands/IRequestParser.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System.Collections.Generic;
@@ -18,4 +18,4 @@ public interface IRequestParser
1818
/// <returns>The <see cref="IDictionary{TKey,TValue}"/>.</returns>
1919
IDictionary<string, string> ParseRequestCommands(HttpContext context);
2020
}
21-
}
21+
}

src/ImageSharp.Web/DependencyInjection/ApplicationBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using Microsoft.AspNetCore.Builder;
@@ -23,4 +23,4 @@ public static IApplicationBuilder UseImageSharp(this IApplicationBuilder app)
2323
return app.UseMiddleware<ImageSharpMiddleware>();
2424
}
2525
}
26-
}
26+
}

src/ImageSharp.Web/DependencyInjection/ImageSharpBuilder.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using Microsoft.Extensions.DependencyInjection;
@@ -14,12 +14,9 @@ internal class ImageSharpBuilder : IImageSharpBuilder
1414
/// Initializes a new instance of the <see cref="ImageSharpBuilder"/> class.
1515
/// </summary>
1616
/// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param>
17-
public ImageSharpBuilder(IServiceCollection services)
18-
{
19-
this.Services = services;
20-
}
17+
public ImageSharpBuilder(IServiceCollection services) => this.Services = services;
2118

2219
/// <inheritdoc/>
2320
public IServiceCollection Services { get; }
2421
}
25-
}
22+
}

src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.IO;
1010
using System.Linq;
1111
using System.Text;
12-
using System.Threading;
1312
using System.Threading.Tasks;
1413
using Microsoft.AspNetCore.Http;
1514
using Microsoft.Extensions.Logging;
@@ -33,25 +32,25 @@ public class ImageSharpMiddleware
3332
/// The write worker used for limiting identical requests.
3433
/// </summary>
3534
private static readonly ConcurrentDictionary<string, Task<ImageWorkerResult>> WriteWorkers
36-
= new ConcurrentDictionary<string, Task<ImageWorkerResult>>(StringComparer.OrdinalIgnoreCase);
35+
= new(StringComparer.OrdinalIgnoreCase);
3736

3837
/// <summary>
3938
/// The read worker used for limiting identical requests.
4039
/// </summary>
4140
private static readonly ConcurrentDictionary<string, Task<ImageWorkerResult>> ReadWorkers
42-
= new ConcurrentDictionary<string, Task<ImageWorkerResult>>(StringComparer.OrdinalIgnoreCase);
41+
= new(StringComparer.OrdinalIgnoreCase);
4342

4443
/// <summary>
4544
/// Used to temporarily store source metadata reads to reduce the overhead of cache lookups.
4645
/// </summary>
4746
private static readonly ConcurrentTLruCache<string, ImageMetadata> SourceMetadataLru
48-
= new ConcurrentTLruCache<string, ImageMetadata>(1024, TimeSpan.FromMinutes(5));
47+
= new(1024, TimeSpan.FromMinutes(5));
4948

5049
/// <summary>
5150
/// Used to temporarily store cache resolver reads to reduce the overhead of cache lookups.
5251
/// </summary>
53-
private static readonly ConcurrentTLruCache<string, ValueTuple<IImageCacheResolver, ImageCacheMetadata>> CacheResolverLru
54-
= new ConcurrentTLruCache<string, ValueTuple<IImageCacheResolver, ImageCacheMetadata>>(1024, TimeSpan.FromMinutes(5));
52+
private static readonly ConcurrentTLruCache<string, (IImageCacheResolver, ImageCacheMetadata)> CacheResolverLru
53+
= new(1024, TimeSpan.FromMinutes(5));
5554

5655
/// <summary>
5756
/// The function processing the Http request.
@@ -268,7 +267,7 @@ private async Task ProcessRequestAsync(
268267
}
269268

270269
// Not cached, or is updated? Let's get it from the image resolver.
271-
var sourceImageMetadata = readResult.SourceImageMetadata;
270+
ImageMetadata sourceImageMetadata = readResult.SourceImageMetadata;
272271

273272
// Enter an asynchronous write worker which prevents multiple writes and delays any reads for the same request.
274273
// This reduces the overheads of unnecessary processing.
@@ -494,7 +493,7 @@ private async Task SendResponseAsync(
494493
this.logger.LogImageServed(imageContext.GetDisplayUrl(), key);
495494

496495
// When stream is null we're sending from the cache.
497-
using (var stream = await cacheResolver.OpenReadAsync())
496+
using (Stream stream = await cacheResolver.OpenReadAsync())
498497
{
499498
await imageContext.SendAsync(stream, metadata);
500499
}

src/ImageSharp.Web/Providers/IImageProvider.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// Copyright (c) Six Labors.
1+
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

44
using System;
5-
using System.Collections.Generic;
65
using System.Threading.Tasks;
76
using Microsoft.AspNetCore.Http;
87
using SixLabors.ImageSharp.Web.Resolvers;
@@ -40,4 +39,4 @@ public interface IImageProvider
4039
/// <returns>The <see cref="IImageResolver"/>.</returns>
4140
Task<IImageResolver> GetAsync(HttpContext context);
4241
}
43-
}
42+
}

tests/ImageSharp.Web.Benchmarks/Caching/CacheHashBaseline.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4-
using System;
54
using System.Security.Cryptography;
65
using System.Text;
76
using SixLabors.ImageSharp.Web.Caching;

0 commit comments

Comments
 (0)