From 0d654ceb0466bbd242d965a23197ad1b1f26f0ae Mon Sep 17 00:00:00 2001 From: Daniel-iel Date: Tue, 30 Apr 2024 16:11:51 -0300 Subject: [PATCH] Fixing names and DeepCode issue --- bench/Spinner.Benchmark/WebSiteInterceptor.cs | 2 +- .../Cache/InterceptorCacheTest.cs | 2 +- .../Helper/Interceptors/CacheInterceptor.cs | 2 +- .../Helper/Interceptors/DecimalInterceptor.cs | 2 +- .../{IInterceptors.cs => IInterceptor.cs} | 2 +- .../Internals/Cache/InterceptorCache.cs | 10 +++++----- src/Spinner/Spinner.cs | 20 ++++++++----------- 7 files changed, 18 insertions(+), 22 deletions(-) rename src/Spinner/Interceptors/{IInterceptors.cs => IInterceptor.cs} (70%) diff --git a/bench/Spinner.Benchmark/WebSiteInterceptor.cs b/bench/Spinner.Benchmark/WebSiteInterceptor.cs index 724fe00..d3f03a3 100644 --- a/bench/Spinner.Benchmark/WebSiteInterceptor.cs +++ b/bench/Spinner.Benchmark/WebSiteInterceptor.cs @@ -2,7 +2,7 @@ namespace Writer.Benchmark { - internal class WebSiteInterceptor : IInterceptors + internal class WebSiteInterceptor : IInterceptor { public object Parse(object propertyValue) { diff --git a/src/Spinner.Test/Cache/InterceptorCacheTest.cs b/src/Spinner.Test/Cache/InterceptorCacheTest.cs index 3b64206..e7803fa 100644 --- a/src/Spinner.Test/Cache/InterceptorCacheTest.cs +++ b/src/Spinner.Test/Cache/InterceptorCacheTest.cs @@ -12,7 +12,7 @@ public void TryGet_WhenCalled_ShouldReturnInterceptorFromCache() { // Arrange const string key = "key"; - IInterceptors interceptor = new CacheInterceptor(); + IInterceptor interceptor = new CacheInterceptor(); InterceptorCache.Add(key, interceptor); // Act diff --git a/src/Spinner.Test/Helper/Interceptors/CacheInterceptor.cs b/src/Spinner.Test/Helper/Interceptors/CacheInterceptor.cs index be17966..5bce179 100644 --- a/src/Spinner.Test/Helper/Interceptors/CacheInterceptor.cs +++ b/src/Spinner.Test/Helper/Interceptors/CacheInterceptor.cs @@ -2,7 +2,7 @@ namespace Spinner.Test.Helper.Interceptors { - internal sealed class CacheInterceptor : IInterceptors + internal sealed class CacheInterceptor : IInterceptor { public object Parse(object obj) { diff --git a/src/Spinner.Test/Helper/Interceptors/DecimalInterceptor.cs b/src/Spinner.Test/Helper/Interceptors/DecimalInterceptor.cs index 2b8d360..687cada 100644 --- a/src/Spinner.Test/Helper/Interceptors/DecimalInterceptor.cs +++ b/src/Spinner.Test/Helper/Interceptors/DecimalInterceptor.cs @@ -3,7 +3,7 @@ namespace Spinner.Test.Helper.Interceptors { - internal sealed class DecimalInterceptor : IInterceptors + internal sealed class DecimalInterceptor : IInterceptor { public object Parse(object obj) { diff --git a/src/Spinner/Interceptors/IInterceptors.cs b/src/Spinner/Interceptors/IInterceptor.cs similarity index 70% rename from src/Spinner/Interceptors/IInterceptors.cs rename to src/Spinner/Interceptors/IInterceptor.cs index e666c90..5c7c7b5 100644 --- a/src/Spinner/Interceptors/IInterceptors.cs +++ b/src/Spinner/Interceptors/IInterceptor.cs @@ -1,6 +1,6 @@ namespace Spinner.Interceptors { - public interface IInterceptors + public interface IInterceptor { object Parse(object obj); } diff --git a/src/Spinner/Internals/Cache/InterceptorCache.cs b/src/Spinner/Internals/Cache/InterceptorCache.cs index 9743219..038d36e 100644 --- a/src/Spinner/Internals/Cache/InterceptorCache.cs +++ b/src/Spinner/Internals/Cache/InterceptorCache.cs @@ -6,21 +6,21 @@ namespace Spinner.Internals.Cache { internal static class InterceptorCache { - private static readonly Dictionary cache = new Dictionary(); + private static readonly Dictionary cache = new Dictionary(); - public static IEnumerable Interceptors + public static IEnumerable Interceptors { get => cache.Values.ToList(); } - public static bool Add(string key, IInterceptors value) + public static bool Add(string key, IInterceptor value) { return cache.TryAdd(key, value); } - public static bool TryGet(string key, out IInterceptors output) + public static bool TryGet(string key, out IInterceptor output) { - if (cache.TryGetValue(key, out IInterceptors value)) + if (cache.TryGetValue(key, out IInterceptor value)) { output = value; return true; diff --git a/src/Spinner/Spinner.cs b/src/Spinner/Spinner.cs index 8505f67..9e89741 100644 --- a/src/Spinner/Spinner.cs +++ b/src/Spinner/Spinner.cs @@ -120,9 +120,9 @@ private void ReadPositionalString(ReadOnlySpan text) if (attribute.Type is not null) { - if (!InterceptorCache.TryGet(attribute.Type.Name, out IInterceptors interceptor)) + if (!InterceptorCache.TryGet(attribute.Type.Name, out IInterceptor interceptor)) { - interceptor = (IInterceptors)Activator.CreateInstance(attribute.Type); + interceptor = (IInterceptor)Activator.CreateInstance(attribute.Type); InterceptorCache.Add(attribute.Type.Name, interceptor); } @@ -190,11 +190,9 @@ private static ReadPropertyAttribute GetReaderProperty(PropertyInfo info) => [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Func PredicateForWriteProperty() { - return (prop) => - { - return prop.GetCustomAttributes(typeof(WritePropertyAttribute), false) - .All(attribute => attribute is WritePropertyAttribute); - }; + return (prop) => prop + .GetCustomAttributes(typeof(WritePropertyAttribute), false) + .All(attribute => attribute is WritePropertyAttribute); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -208,11 +206,9 @@ private static Func PredicateForOrderByWriteProperty() [MethodImpl(MethodImplOptions.AggressiveInlining)] private static Func PredicateForReadProperty() { - return (prop) => - { - return prop.GetCustomAttributes(typeof(ReadPropertyAttribute), false) - .All(attribute => attribute is ReadPropertyAttribute); - }; + return (prop) => prop + .GetCustomAttributes(typeof(ReadPropertyAttribute), false) + .All(attribute => attribute is ReadPropertyAttribute); } } } \ No newline at end of file