Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed Mar 14, 2024
1 parent 1a3212e commit 8e96a62
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/ArgDependencyNodeBuilder.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 sealed class ArgDependencyNodeBuilder : IBuilder<MdSetup, IEnumerable<DependencyNode>>
{
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Arguments.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 Arguments : IArguments
{
Expand Down
11 changes: 9 additions & 2 deletions src/Pure.DI.Core/Core/BaseSymbolsProvider.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
namespace Pure.DI.Core;
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal class BaseSymbolsProvider : IBaseSymbolsProvider
{
public IEnumerable<ITypeSymbol> GetBaseSymbols(ITypeSymbol symbol, int deep = int.MaxValue)
{
if (deep < 0)
{
yield break;
}

deep--;
while (true)
{
yield return symbol;
foreach (var type in symbol.AllInterfaces.SelectMany(i => GetBaseSymbols(i, --deep)))
foreach (var type in symbol.AllInterfaces.SelectMany(i => GetBaseSymbols(i, deep)))
{
yield return type;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ private string FormatInjection(Injection injection, FormatOptions options) =>
private string FormatDependency(Dependency dependency, FormatOptions options) =>
$"{(dependency.Injection.Tag == default ? "" : FormatTag(dependency.Injection.Tag) + " ")}{FormatSymbol(dependency.Injection.Type, options)}";

private string FormatTag(object? tag) =>
private static string FormatTag(object? tag) =>
tag != default ? $"{tag.ValueToString("").Replace("\"", "\\\"")} " : "";

private string FormatTags(IEnumerable<object?> tags) =>
private static string FormatTags(IEnumerable<object?> tags) =>
string.Join(", ", tags.Distinct().Select(FormatTag).OrderBy(i => i));

private string FormatSymbol(ISymbol? symbol, FormatOptions options) =>
Expand Down Expand Up @@ -238,7 +238,7 @@ private string FormatType(ISymbol? symbol, FormatOptions options)
string FormatSymbolLocal(ITypeSymbol i) => FormatSymbol(i, options);
}

private string Format(Accessibility accessibility) =>
private static string Format(Accessibility accessibility) =>
accessibility switch
{
Accessibility.NotApplicable => "",
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/Comments.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;

using System.Text.RegularExpressions;

Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/Formatter.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 Formatter(
ITypeResolver typeResolver,
Expand Down
1 change: 0 additions & 1 deletion src/Pure.DI.Core/Core/Code/RootMethodsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private void BuildRoot(CompositionCode composition, Root root)
name.Append(root.DisplayName);

var typeArgs = root.TypeDescription.TypeArgs;
var constraints = new List<string>();
if (typeArgs.Count > 0)
{
name.Append('<');
Expand Down
2 changes: 1 addition & 1 deletion src/Pure.DI.Core/Core/Code/TypeDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ public readonly record struct TypeDescription(
ITypeParameterSymbol? TypeParam)
{
public override string ToString() => Name;
};
}
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Code/TypeResolver.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 TypeResolver(IMarker marker)
: ITypeResolver
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/ConstructDependencyNodeBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ReSharper disable ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal sealed class ConstructDependencyNodeBuilder : IBuilder<MdSetup, IEnumerable<DependencyNode>>
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/FactoryDependencyNodeBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// ReSharper disable ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal sealed class FactoryDependencyNodeBuilder : IBuilder<MdSetup, IEnumerable<DependencyNode>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ReSharper disable ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
// ReSharper disable ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
// ReSharper disable ConvertToAutoPropertyWhenPossible
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal sealed class ImplementationDependencyNodeBuilder(
Expand Down
3 changes: 2 additions & 1 deletion src/Pure.DI.Core/Core/Profiler.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;

using System.Diagnostics;

Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Core/RootDependencyNodeBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable ClassNeverInstantiated.Global
namespace Pure.DI.Core;

internal sealed class RootDependencyNodeBuilder : IBuilder<MdSetup, IEnumerable<DependencyNode>>
Expand Down
1 change: 1 addition & 0 deletions src/Pure.DI.Core/Source.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ReSharper disable NotAccessedPositionalProperty.Global
namespace Pure.DI;

public readonly record struct Source(
Expand Down

0 comments on commit 8e96a62

Please sign in to comment.