File tree Expand file tree Collapse file tree
tests/Pure.DI.IntegrationTests Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments