diff --git a/build/Source.ruleset b/build/Source.ruleset index 459e4e0..8994858 100644 --- a/build/Source.ruleset +++ b/build/Source.ruleset @@ -1,9 +1,11 @@ - - + + - - + + + + @@ -12,23 +14,45 @@ - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/Test.ruleset b/build/Test.ruleset index 3c26c01..b64a37a 100644 --- a/build/Test.ruleset +++ b/build/Test.ruleset @@ -1,16 +1,14 @@ - - + + - - - - + + - - - + - + + + @@ -20,37 +18,93 @@ - - - + - + - - - + + + + + - + - + - + + + - + - + - + - + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -58,11 +112,11 @@ - + - + - + @@ -82,6 +136,13 @@ + + + + + + + diff --git a/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs index 73dfc57..206e3d6 100644 --- a/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs @@ -46,7 +46,7 @@ internal Action ConfigurationAction /// public void RegisterActorFactory( - ILifetimeScope container, + ILifetimeScope lifetimeScope, Type actorServiceType, Func? stateManagerFactory = null, IActorStateProvider? stateProvider = null, @@ -59,7 +59,7 @@ public void RegisterActorFactory( ActorBase ActorFactory(ActorService actorService, ActorId actorId) { var tag = lifetimeScopeTag ?? Constants.DefaultLifetimeScopeTag; - var lifetimeScope = container.BeginLifetimeScope(tag, builder => + var serviceScope = lifetimeScope.BeginLifetimeScope(tag, builder => { builder.RegisterInstance(context) .As() @@ -74,20 +74,20 @@ ActorBase ActorFactory(ActorService actorService, ActorId actorId) try { - var actor = lifetimeScope.Resolve(); + var actor = serviceScope.Resolve(); return actor; } catch (Exception ex) { // Proactively dispose lifetime scope as interceptor will not be called. - lifetimeScope.Dispose(); + serviceScope.Dispose(); ConstructorExceptionCallback(ex); throw; } } - return (ActorService)container.Resolve( + return (ActorService)lifetimeScope.Resolve( actorServiceType, new TypedParameter(typeof(StatefulServiceContext), context), new TypedParameter(typeof(ActorTypeInformation), actorTypeInfo), diff --git a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj b/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj index 85244ca..d18354a 100644 --- a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj +++ b/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj @@ -21,6 +21,7 @@ true ../../build/Source.ruleset AllEnabledByDefault + true enable x64 @@ -68,6 +69,10 @@ all + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs index 3e231b4..c3952d4 100644 --- a/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs @@ -45,13 +45,13 @@ internal Action ConfigurationAction /// public void RegisterStatefulServiceFactory( - ILifetimeScope container, string serviceTypeName, object? lifetimeScopeTag = null) + ILifetimeScope lifetimeScope, string serviceTypeName, object? lifetimeScopeTag = null) where TService : StatefulServiceBase { ServiceRuntime.RegisterServiceAsync(serviceTypeName, context => { var tag = lifetimeScopeTag ?? Constants.DefaultLifetimeScopeTag; - var lifetimeScope = container.BeginLifetimeScope(tag, builder => + var serviceScope = lifetimeScope.BeginLifetimeScope(tag, builder => { builder.RegisterInstance(context) .As() @@ -62,13 +62,13 @@ public void RegisterStatefulServiceFactory( try { - var service = lifetimeScope.Resolve(); + var service = serviceScope.Resolve(); return service; } catch (Exception ex) { // Proactively dispose lifetime scope as interceptor will not be called. - lifetimeScope.Dispose(); + serviceScope.Dispose(); ConstructorExceptionCallback(ex); throw; diff --git a/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs index 958af1a..d4492e9 100644 --- a/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs @@ -45,13 +45,13 @@ internal Action ConfigurationAction /// public void RegisterStatelessServiceFactory( - ILifetimeScope container, string serviceTypeName, object? lifetimeScopeTag = null) + ILifetimeScope lifetimeScope, string serviceTypeName, object? lifetimeScopeTag = null) where TService : StatelessService { ServiceRuntime.RegisterServiceAsync(serviceTypeName, context => { var tag = lifetimeScopeTag ?? Constants.DefaultLifetimeScopeTag; - var lifetimeScope = container.BeginLifetimeScope(tag, builder => + var serviceScope = lifetimeScope.BeginLifetimeScope(tag, builder => { builder.RegisterInstance(context) .As() @@ -62,13 +62,13 @@ public void RegisterStatelessServiceFactory( try { - var service = lifetimeScope.Resolve(); + var service = serviceScope.Resolve(); return service; } catch (Exception ex) { // Proactively dispose lifetime scope as interceptor will not be called. - lifetimeScope.Dispose(); + serviceScope.Dispose(); ConstructorExceptionCallback(ex); throw; diff --git a/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj b/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj index a9d428a..074c242 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj +++ b/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj @@ -8,6 +8,8 @@ ../../Autofac.snk true ../../build/Test.ruleset + AllEnabledByDefault + true false latest enable @@ -47,6 +49,10 @@ all + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + all diff --git a/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj b/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj index 547f496..13c0dbd 100644 --- a/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj +++ b/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj @@ -6,6 +6,8 @@ ../../Autofac.snk true ../../build/Test.ruleset + AllEnabledByDefault + true false latest @@ -16,6 +18,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +