Skip to content

Commit

Permalink
Fixing names and DeepCode issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-iel committed Apr 30, 2024
1 parent 48b0f55 commit 0d654ce
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion bench/Spinner.Benchmark/WebSiteInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Writer.Benchmark
{
internal class WebSiteInterceptor : IInterceptors
internal class WebSiteInterceptor : IInterceptor
{
public object Parse(object propertyValue)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spinner.Test/Cache/InterceptorCacheTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Spinner.Test/Helper/Interceptors/CacheInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spinner.Test.Helper.Interceptors
{
internal sealed class CacheInterceptor : IInterceptors
internal sealed class CacheInterceptor : IInterceptor
{
public object Parse(object obj)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Spinner.Test/Helper/Interceptors/DecimalInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Spinner.Test.Helper.Interceptors
{
internal sealed class DecimalInterceptor : IInterceptors
internal sealed class DecimalInterceptor : IInterceptor
{
public object Parse(object obj)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Spinner.Interceptors
{
public interface IInterceptors
public interface IInterceptor
{
object Parse(object obj);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Spinner/Internals/Cache/InterceptorCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ namespace Spinner.Internals.Cache
{
internal static class InterceptorCache
{
private static readonly Dictionary<string, IInterceptors> cache = new Dictionary<string, IInterceptors>();
private static readonly Dictionary<string, IInterceptor> cache = new Dictionary<string, IInterceptor>();

public static IEnumerable<IInterceptors> Interceptors
public static IEnumerable<IInterceptor> 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;
Expand Down
20 changes: 8 additions & 12 deletions src/Spinner/Spinner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ private void ReadPositionalString(ReadOnlySpan<char> 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);
}

Expand Down Expand Up @@ -190,11 +190,9 @@ private static ReadPropertyAttribute GetReaderProperty(PropertyInfo info) =>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Func<PropertyInfo, bool> 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);

Check warning on line 195 in src/Spinner/Spinner.cs

View workflow job for this annotation

GitHub Actions / build (8.0.204)

Struct instance method being used for delegate creation, this will result in a boxing instruction

Check warning on line 195 in src/Spinner/Spinner.cs

View workflow job for this annotation

GitHub Actions / build (8.0.204)

Struct instance method being used for delegate creation, this will result in a boxing instruction
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand All @@ -208,11 +206,9 @@ private static Func<PropertyInfo, ushort> PredicateForOrderByWriteProperty()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static Func<PropertyInfo, bool> 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);

Check warning on line 211 in src/Spinner/Spinner.cs

View workflow job for this annotation

GitHub Actions / build (8.0.204)

Struct instance method being used for delegate creation, this will result in a boxing instruction

Check warning on line 211 in src/Spinner/Spinner.cs

View workflow job for this annotation

GitHub Actions / build (8.0.204)

Struct instance method being used for delegate creation, this will result in a boxing instruction
}
}
}

0 comments on commit 0d654ce

Please sign in to comment.