Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Dec 19, 2024
1 parent 5f0aaa9 commit 034dc0a
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 49 deletions.
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/Attributes.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ReSharper disable HeapView.DelegateAllocation

// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class Attributes(ISemantic semantic)
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/BindingsValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable CS9113 // Parameter is unread.
// ReSharper disable ClassNeverInstantiated.Global
#pragma warning disable CS9113 // Parameter is unread.
namespace Pure.DI.Core;

internal class BindingsValidator(ILogger logger, IRegistry<MdBinding> registry)
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/Compilations.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core.Code;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core.Code;

public class Compilations : ICompilations
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/Injections.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core.Code;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core.Code;

internal class Injections : IInjections
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/Locks.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core.Code;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core.Code;

internal class Locks(ITypes types) : ILocks
{
Expand Down
5 changes: 2 additions & 3 deletions src/Pure.DI.Core/Core/Code/TagClassBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core.Code;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core.Code;

internal class TagClassBuilder(
IInformation information,
Expand Down Expand Up @@ -67,8 +68,6 @@ where dependency.Injection.Tag is string

code.AppendLine("/// </list>");
}


}

code.AppendLine("/// </summary>");
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/TriviaTools.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core.Code;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core.Code;

public class TriviaTools : ITriviaTools
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/GraphWalker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class GraphWalker<TContext, T> : IGraphWalker<TContext, T>
{
Expand Down
4 changes: 1 addition & 3 deletions src/Pure.DI.Core/Core/IRegistry.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
namespace Pure.DI.Core;

internal interface IRegistry<T>
internal interface IRegistry<in T>
{
bool IsRegistered(MdSetup setup, T value);

IEnumerable<T> GetRegistrations();
}
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/InstanceDpProvider.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class InstanceDpProvider(
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/LifetimeAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class LifetimeAnalyzer : ILifetimeAnalyzer
{
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/Models/DpImplementation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ReSharper disable HeapView.ObjectAllocation

// ReSharper disable NotAccessedPositionalProperty.Global
namespace Pure.DI.Core.Models;

internal record DpImplementation(
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/Models/LogEntry.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ReSharper disable HeapView.BoxingAllocation

// ReSharper disable NotAccessedPositionalProperty.Global
namespace Pure.DI.Core.Models;

public readonly record struct LogEntry(
Expand Down
15 changes: 3 additions & 12 deletions src/Pure.DI.Core/Core/Registry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,7 @@ public bool IsRegistered(MdSetup setup, T value)
}
}

public IEnumerable<T> GetRegistrations()
{
List<T> result;
lock (_registered)
{
result = _registered.Select(i => i.Value).ToList();
}

return result;
}

private readonly record struct Key(CompositionName CompositionName, T Value);
private readonly record struct Key(
CompositionName CompositionName,
T Value);
}
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/RootAccessModifierResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
namespace Pure.DI.Core;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class RootAccessModifierResolver : IRootAccessModifierResolver
{
Expand Down
30 changes: 10 additions & 20 deletions src/Pure.DI.Core/Core/Semantic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,25 @@ when memberAccessExpressionSyntax.IsKind(SyntaxKind.SimpleMemberAccessExpression
break;

case nameof(Tag) when typeof(T) == typeof(object):
switch (valueStr)
return valueStr switch
{
case nameof(Tag.Type) when IsSpecialType(semanticModel, node, SpecialType.Tag):
return (T)(object)Tag.Type;

case nameof(Tag.Unique) when IsSpecialType(semanticModel, node, SpecialType.Tag):
return (T)(object)Tag.Unique;

default:
return (T)smartTags.Register(valueStr);
}
nameof(Tag.Type) when IsSpecialType(semanticModel, node, SpecialType.Tag) => (T)(object)Tag.Type,
nameof(Tag.Unique) when IsSpecialType(semanticModel, node, SpecialType.Tag) => (T)(object)Tag.Unique,
_ => (T)smartTags.Register(valueStr)
};
}
}

break;
}

case IdentifierNameSyntax identifierNameSyntax when typeof(T) == typeof(object):
switch (identifierNameSyntax.Identifier.Text)
return identifierNameSyntax.Identifier.Text switch
{
case nameof(Tag.Type) when IsSpecialType(semanticModel, node, SpecialType.Tag):
return (T)(object)Tag.Type;

case nameof(Tag.Unique) when IsSpecialType(semanticModel, node, SpecialType.Tag):
return (T)(object)Tag.Unique;

default:
return (T)smartTags.Register(identifierNameSyntax.Identifier.Text);
}
nameof(Tag.Type) when IsSpecialType(semanticModel, node, SpecialType.Tag) => (T)(object)Tag.Type,
nameof(Tag.Unique) when IsSpecialType(semanticModel, node, SpecialType.Tag) => (T)(object)Tag.Unique,
_ => (T)smartTags.Register(identifierNameSyntax.Identifier.Text)
};

case InvocationExpressionSyntax invocationExpressionSyntax:
{
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/SmartTags.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ReSharper disable InvertIf
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class SmartTags : ISmartTags
Expand Down
7 changes: 5 additions & 2 deletions src/Pure.DI.Core/Core/SpecialTypeKey.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
namespace Pure.DI.Core;
// ReSharper disable NotAccessedPositionalProperty.Global
namespace Pure.DI.Core;

internal record SpecialTypeKey(SpecialType SpecialType, Compilation Compilation);
internal record SpecialTypeKey(
SpecialType SpecialType,
Compilation Compilation);
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/TagOnSitesValidator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma warning disable CS9113 // Parameter is unread.
// ReSharper disable ClassNeverInstantiated.Global
#pragma warning disable CS9113 // Parameter is unread.
namespace Pure.DI.Core;

internal class TagOnSitesValidator(ILogger logger, IRegistry<MdInjectionSite> registry)
Expand Down

0 comments on commit 034dc0a

Please sign in to comment.