Skip to content

Commit e7b3025

Browse files
Minor
1 parent 37d7b01 commit e7b3025

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

src/Pure.DI.Core/Core/ApiInvocationProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ tag is MemberAccessExpressionSyntax memberAccessExpression
10951095
return valueType;
10961096
}
10971097

1098+
// ReSharper disable once ConvertIfStatementToReturnStatement
10981099
if (semanticModel.GetOperation(argumentSyntax.Expression) is { Type: {} declarationType })
10991100
{
11001101
return declarationType;

tests/Pure.DI.IntegrationTests/RootsTests.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,70 @@ public static void Main()
497497
result.StdOut.ShouldBe(["Initialize 1 Abc", "Initialize 1 Abc"], result);
498498
}
499499

500+
[Fact]
501+
public async Task ShouldSupportRootWhenNameStaticSmartTag()
502+
{
503+
// Given
504+
505+
// When
506+
var result = await """
507+
using System;
508+
using Pure.DI;
509+
using static Pure.DI.Name;
510+
511+
namespace Sample
512+
{
513+
interface IDependency {}
514+
515+
class Dependency: IDependency
516+
{
517+
}
518+
519+
interface IService
520+
{
521+
IDependency? Dep { get; }
522+
}
523+
524+
class Service: IService
525+
{
526+
[Ordinal(1)]
527+
internal void Initialize([Tag(374)] string depName)
528+
{
529+
Console.WriteLine($"Initialize 1 {depName}");
530+
}
531+
532+
[Ordinal(0)]
533+
public IDependency? Dep { get; set; }
534+
}
535+
536+
static class Setup
537+
{
538+
private static void SetupComposition()
539+
{
540+
DI.Setup("Composition")
541+
.Bind(374).To(_ => "Abc")
542+
.Bind().To<Dependency>()
543+
.Root<Service>(Root);
544+
}
545+
}
546+
547+
public class Program
548+
{
549+
public static void Main()
550+
{
551+
var composition = new Composition();
552+
var service = composition.Resolve<Service>();
553+
var service2 = composition.Root;
554+
}
555+
}
556+
}
557+
""".RunAsync();
558+
559+
// Then
560+
result.Success.ShouldBeTrue(result);
561+
result.StdOut.ShouldBe(["Initialize 1 Abc", "Initialize 1 Abc"], result);
562+
}
563+
500564
[Fact]
501565
public async Task ShouldSupportRootWhenNameTemplate()
502566
{

0 commit comments

Comments
 (0)