Skip to content

Commit 36fefdf

Browse files
Minor code refactorings
1 parent f772c13 commit 36fefdf

6 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/Pure.DI.Core/Core/Code/CompositionBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public CompositionCode Build(DependencyGraph graph)
118118

119119
var setupContextArgs = new List<SetupContextArg>();
120120
var setupContextNames = new HashSet<string>(StringComparer.Ordinal);
121+
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
121122
foreach (var binding in graph.Source.Bindings)
122123
{
123124
var arg = binding.Arg;

src/Pure.DI.Core/Core/Code/FactoryCodeBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ private record struct LinePrefix(ReadOnlyMemory<char> Line, int PrefixLength);
454454

455455
private static void AddLinePrefixes(SourceText text, List<LinePrefix> linePrefixes)
456456
{
457+
// ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
457458
foreach (var textLine in text.Lines)
458459
{
459460
var line = text.ToString(textLine.Span);

src/Pure.DI.Core/Core/Code/FactoryRewriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public override SyntaxNode VisitExpressionStatement(ExpressionStatementSyntax no
207207
else
208208
{
209209
var firstAncestor = node.Ancestors().FirstOrDefault();
210-
var prefix = firstAncestor is not null ? firstAncestor.GetLeadingTrivia() : new SyntaxTriviaList().Add(SyntaxFactory.LineFeed);
210+
var prefix = firstAncestor?.GetLeadingTrivia() ?? new SyntaxTriviaList().Add(SyntaxFactory.LineFeed);
211211
newNode = SyntaxFactory.Block().AddStatements(
212212
SyntaxFactory.ExpressionStatement(expressionSyntax)
213213
.WithLeadingTrivia(new SyntaxTriviaList().Add(SyntaxFactory.LineFeed).AddRange(node.GetLeadingTrivia()))

src/Pure.DI.Core/Core/Code/TagClassBuilder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// ReSharper disable ClassNeverInstantiated.Global
22
// ReSharper disable UnusedVariable
3+
// ReSharper disable ConvertIfStatementToSwitchStatement
34
namespace Pure.DI.Core.Code;
45

56
using static LinesExtensions;

src/Pure.DI.Core/Core/Metadata.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public bool IsMetadata(SyntaxNode node, SemanticModel semanticModel, Cancellatio
1515
return false;
1616
}
1717

18-
for (var curInvocation = invocation; curInvocation is not null;)
18+
for (var curInvocation = invocation;;)
1919
{
2020
if (cancellationToken.IsCancellationRequested)
2121
{

src/Pure.DI.Core/Core/MetadataBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// ReSharper disable HeapView.ClosureAllocation
88
// ReSharper disable LoopCanBeConvertedToQuery
99

10+
// ReSharper disable ForCanBeConvertedToForeach
1011
namespace Pure.DI.Core;
1112

1213
sealed class MetadataBuilder(
@@ -342,8 +343,7 @@ static List<MdTagOnSites> BuildTagOn(ImmutableArray<MdBinding> bindings)
342343
{
343344
foreach (var tag in contract.Tags)
344345
{
345-
if (tag.Value is MdTagOnSites tagOnSites
346-
&& tagOnSites.InjectionSites.Length > 0
346+
if (tag.Value is MdTagOnSites { InjectionSites.Length: > 0 } tagOnSites
347347
&& seen.Add(tagOnSites))
348348
{
349349
result.Add(tagOnSites);

0 commit comments

Comments
 (0)