From 7565e6b76971a62fc335f91db4667be1530466fe Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Wed, 14 Sep 2022 11:30:57 -0500 Subject: [PATCH 1/3] Package update to latest SF version --- Autofac.ServiceFabric.sln | 20 +++++++++++++++--- .../Autofac.Integration.ServiceFabric.csproj | 21 ++++++++++--------- ...ofac.Integration.ServiceFabric.Test.csproj | 8 +++---- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Autofac.ServiceFabric.sln b/Autofac.ServiceFabric.sln index a48d5a0..8ef1269 100644 --- a/Autofac.ServiceFabric.sln +++ b/Autofac.ServiceFabric.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.30503.244 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric", "src\Autofac.Integration.ServiceFabric\Autofac.Integration.ServiceFabric.csproj", "{6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}" EndProject @@ -11,31 +11,45 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Scenario.InternalsVisi EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EFD7983F-DC17-4C4E-A006-0A64079985ED}" ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore appveyor.yml = appveyor.yml build.ps1 = build.ps1 global.json = global.json NuGet.Config = NuGet.Config - .gitignore = .gitignore EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|x64.ActiveCfg = Debug|Any CPU + {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|x64.Build.0 = Debug|Any CPU {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|Any CPU.ActiveCfg = Release|Any CPU {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|Any CPU.Build.0 = Release|Any CPU + {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|x64.ActiveCfg = Release|Any CPU + {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|x64.Build.0 = Release|Any CPU {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|x64.ActiveCfg = Debug|Any CPU + {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|x64.Build.0 = Debug|Any CPU {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|Any CPU.Build.0 = Release|Any CPU + {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|x64.ActiveCfg = Release|Any CPU + {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|x64.Build.0 = Release|Any CPU {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|x64.ActiveCfg = Debug|Any CPU + {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|x64.Build.0 = Debug|Any CPU {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|Any CPU.ActiveCfg = Release|Any CPU {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|Any CPU.Build.0 = Release|Any CPU + {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|x64.ActiveCfg = Release|Any CPU + {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj b/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj index 289712c..fef2af7 100644 --- a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj +++ b/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj @@ -39,22 +39,23 @@ - - - + + + All - - All + + all + runtime; build; native; contentfiles; analyzers; buildtransitive - - - - + + + + All - + All 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 ae27458..43fc169 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj +++ b/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj @@ -19,10 +19,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers From 818a7807f5e76b1bfca618f32ca3709d11290bb7 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Wed, 14 Sep 2022 18:53:30 -0500 Subject: [PATCH 2/3] Split out src and tests to separate .Services and .Actors projects --- Autofac.ServiceFabric.sln | 104 ++++++++++---- Autofac.ServiceFabric.sln.bak | 114 ++++++++++++++++ .../ActorFactoryRegistration.cs | 10 +- .../ActorInterceptor.cs | 2 +- .../AssemblyInfo.cs | 4 +- ...c.Integration.ServiceFabric.Actors.csproj} | 23 ++-- .../AutofacActorExtensions.cs | 12 +- .../Constants.cs | 2 +- .../IActorFactoryRegistration.cs | 14 +- .../RegistrationExtensions.cs | 116 ++++++++++++++++ .../TypeExtensions.cs | 2 +- .../TypeExtensionsResources.Designer.cs | 22 +-- .../TypeExtensionsResources.resx | 0 .../AssemblyInfo.cs | 11 ++ ....Integration.ServiceFabric.Services.csproj | 91 ++++++++++++ .../AutofacServiceExtensions.cs | 8 +- ...ofacServiceExtensionsResources.Designer.cs | 6 +- .../AutofacServiceExtensionsResources.resx | 3 +- .../Constants.cs | 7 + .../IStatefulServiceFactoryRegistration.cs | 12 +- .../IStatelessServiceFactoryRegistration.cs | 12 +- .../RegistrationExtensions.cs | 26 +--- .../ServiceInterceptor.cs | 2 +- .../StatefulServiceFactoryRegistration.cs | 6 +- .../StatelessServiceFactoryRegistration.cs | 6 +- .../TypeExtensions.cs | 56 ++++++++ .../TypeExtensionsResources.Designer.cs | 90 ++++++++++++ .../TypeExtensionsResources.resx | 129 ++++++++++++++++++ .../ActorInterceptorTests.cs | 2 +- .../Assertions.cs | 2 +- ...tegration.ServiceFabric.Actors.Test.csproj | 45 ++++++ .../AutofacActorExtensionsTests.cs | 4 +- .../RegistrationExtensionsTests.cs | 31 +++++ .../ServiceFabricModuleTests.cs | 72 ++++++++++ .../Assertions.cs | 37 +++++ ...ration.ServiceFabric.Services.Test.csproj} | 19 ++- .../AutofacServiceExtensionsTests.cs | 64 +++++---- .../RegistrationExtensionsTests.cs | 8 +- .../ServiceFabricModuleTests.cs | 62 +-------- .../ServiceInterceptorTests.cs | 2 +- .../AssemblyInfo.cs | 5 + .../InternalsVisibleActor.cs | 2 +- ...t.Scenario.InternalsVisible.Actors.csproj} | 20 +-- .../AssemblyInfo.cs | 5 + .../InternalsVisibleToStatefulService.cs} | 2 +- .../InternalsVisibleToStatelessService.cs} | 2 +- ....Scenario.InternalsVisible.Services.csproj | 18 +++ .../Properties/AssemblyInfo.cs | 5 - 48 files changed, 1061 insertions(+), 236 deletions(-) create mode 100644 Autofac.ServiceFabric.sln.bak rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/ActorFactoryRegistration.cs (95%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/ActorInterceptor.cs (97%) rename src/{Autofac.Integration.ServiceFabric/Properties => Autofac.Integration.ServiceFabric.Actors}/AssemblyInfo.cs (51%) rename src/{Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj => Autofac.Integration.ServiceFabric.Actors/Autofac.Integration.ServiceFabric.Actors.csproj} (85%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/AutofacActorExtensions.cs (93%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/Constants.cs (69%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/IActorFactoryRegistration.cs (84%) create mode 100644 src/Autofac.Integration.ServiceFabric.Actors/RegistrationExtensions.cs rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/TypeExtensions.cs (97%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/TypeExtensionsResources.Designer.cs (90%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Actors}/TypeExtensionsResources.resx (100%) create mode 100644 src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs create mode 100644 src/Autofac.Integration.ServiceFabric.Services/Autofac.Integration.ServiceFabric.Services.csproj rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/AutofacServiceExtensions.cs (96%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/AutofacServiceExtensionsResources.Designer.cs (92%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/AutofacServiceExtensionsResources.resx (99%) create mode 100644 src/Autofac.Integration.ServiceFabric.Services/Constants.cs rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/IStatefulServiceFactoryRegistration.cs (82%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/IStatelessServiceFactoryRegistration.cs (82%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/RegistrationExtensions.cs (84%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/ServiceInterceptor.cs (97%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/StatefulServiceFactoryRegistration.cs (95%) rename src/{Autofac.Integration.ServiceFabric => Autofac.Integration.ServiceFabric.Services}/StatelessServiceFactoryRegistration.cs (95%) create mode 100644 src/Autofac.Integration.ServiceFabric.Services/TypeExtensions.cs create mode 100644 src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.Designer.cs create mode 100644 src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.resx rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Actors.Test}/ActorInterceptorTests.cs (93%) rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Actors.Test}/Assertions.cs (95%) create mode 100644 test/Autofac.Integration.ServiceFabric.Actors.Test/Autofac.Integration.ServiceFabric.Actors.Test.csproj rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Actors.Test}/AutofacActorExtensionsTests.cs (99%) create mode 100644 test/Autofac.Integration.ServiceFabric.Actors.Test/RegistrationExtensionsTests.cs create mode 100644 test/Autofac.Integration.ServiceFabric.Actors.Test/ServiceFabricModuleTests.cs create mode 100644 test/Autofac.Integration.ServiceFabric.Services.Test/Assertions.cs rename test/{Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj => Autofac.Integration.ServiceFabric.Services.Test/Autofac.Integration.ServiceFabric.Services.Test.csproj} (64%) rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Services.Test}/AutofacServiceExtensionsTests.cs (90%) rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Services.Test}/RegistrationExtensionsTests.cs (82%) rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Services.Test}/ServiceFabricModuleTests.cs (68%) rename test/{Autofac.Integration.ServiceFabric.Test => Autofac.Integration.ServiceFabric.Services.Test}/ServiceInterceptorTests.cs (93%) create mode 100644 test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs rename test/{Test.Scenario.InternalsVisible => Test.Scenario.InternalsVisible.Actors}/InternalsVisibleActor.cs (87%) rename test/{Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj => Test.Scenario.InternalsVisible.Actors/Test.Scenario.InternalsVisible.Actors.csproj} (53%) create mode 100644 test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs rename test/{Test.Scenario.InternalsVisible/InternalsVisibleStatefulService.cs => Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatefulService.cs} (90%) rename test/{Test.Scenario.InternalsVisible/InternalsVisibleStatelessService.cs => Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatelessService.cs} (87%) create mode 100644 test/Test.Scenario.InternalsVisible.Services/Test.Scenario.InternalsVisible.Services.csproj delete mode 100644 test/Test.Scenario.InternalsVisible/Properties/AssemblyInfo.cs diff --git a/Autofac.ServiceFabric.sln b/Autofac.ServiceFabric.sln index 8ef1269..be4a4c0 100644 --- a/Autofac.ServiceFabric.sln +++ b/Autofac.ServiceFabric.sln @@ -3,12 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric", "src\Autofac.Integration.ServiceFabric\Autofac.Integration.ServiceFabric.csproj", "{6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Test", "test\Autofac.Integration.ServiceFabric.Test\Autofac.Integration.ServiceFabric.Test.csproj", "{A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Scenario.InternalsVisible", "test\Test.Scenario.InternalsVisible\Test.Scenario.InternalsVisible.csproj", "{1707F51B-7E92-4905-BA3A-AFE26A12B706}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EFD7983F-DC17-4C4E-A006-0A64079985ED}" ProjectSection(SolutionItems) = preProject .gitignore = .gitignore @@ -18,6 +12,24 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution NuGet.Config = NuGet.Config EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Actors", "src\Autofac.Integration.ServiceFabric.Actors\Autofac.Integration.ServiceFabric.Actors.csproj", "{92F547AA-A38D-44B7-B1ED-AAF42F3748A3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Services", "src\Autofac.Integration.ServiceFabric.Services\Autofac.Integration.ServiceFabric.Services.csproj", "{F76F8A9D-F1F0-4652-90A8-1D1C25657F66}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Services.Test", "test\Autofac.Integration.ServiceFabric.Services.Test\Autofac.Integration.ServiceFabric.Services.Test.csproj", "{B8F4F393-FAB8-418F-A505-6477E56A0B2D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Actors.Test", "test\Autofac.Integration.ServiceFabric.Actors.Test\Autofac.Integration.ServiceFabric.Actors.Test.csproj", "{1D2168A0-7D56-4A90-9C08-068571C54F23}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4F3D8A91-2410-40B5-96E6-559360D39E6D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actors", "Actors", "{7180610C-3B07-45B6-BEE9-4999F24E9A3B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{0397F396-6F6A-45C7-806A-AADD6E35E579}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Scenario.InternalsVisible.Actors", "test\Test.Scenario.InternalsVisible.Actors\Test.Scenario.InternalsVisible.Actors.csproj", "{9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Scenario.InternalsVisible.Services", "test\Test.Scenario.InternalsVisible.Services\Test.Scenario.InternalsVisible.Services.csproj", "{E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -26,34 +38,66 @@ Global Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|x64.ActiveCfg = Debug|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Debug|x64.Build.0 = Debug|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|Any CPU.Build.0 = Release|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|x64.ActiveCfg = Release|Any CPU - {6956F17D-A87B-4FAB-8CA8-0A6AB8A14537}.Release|x64.Build.0 = Release|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|x64.ActiveCfg = Debug|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Debug|x64.Build.0 = Debug|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|Any CPU.Build.0 = Release|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|x64.ActiveCfg = Release|Any CPU - {A3183165-EEDC-4177-A72C-2B9E8D5BFFA0}.Release|x64.Build.0 = Release|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|x64.ActiveCfg = Debug|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Debug|x64.Build.0 = Debug|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|Any CPU.Build.0 = Release|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|x64.ActiveCfg = Release|Any CPU - {1707F51B-7E92-4905-BA3A-AFE26A12B706}.Release|x64.Build.0 = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|x64.ActiveCfg = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|x64.Build.0 = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|Any CPU.Build.0 = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|x64.ActiveCfg = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|x64.Build.0 = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|x64.ActiveCfg = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|x64.Build.0 = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|Any CPU.Build.0 = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|x64.ActiveCfg = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|x64.Build.0 = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|x64.Build.0 = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|Any CPU.Build.0 = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|x64.ActiveCfg = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|x64.Build.0 = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|x64.ActiveCfg = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|x64.Build.0 = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|Any CPU.Build.0 = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|x64.ActiveCfg = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|x64.Build.0 = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|x64.ActiveCfg = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|x64.Build.0 = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|Any CPU.Build.0 = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|x64.ActiveCfg = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|x64.Build.0 = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|x64.ActiveCfg = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|x64.Build.0 = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|Any CPU.Build.0 = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|x64.ActiveCfg = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + {B8F4F393-FAB8-418F-A505-6477E56A0B2D} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + {1D2168A0-7D56-4A90-9C08-068571C54F23} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9C702E07-7135-47CD-9650-31EB57F0592A} EndGlobalSection diff --git a/Autofac.ServiceFabric.sln.bak b/Autofac.ServiceFabric.sln.bak new file mode 100644 index 0000000..306dc06 --- /dev/null +++ b/Autofac.ServiceFabric.sln.bak @@ -0,0 +1,114 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32825.248 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EFD7983F-DC17-4C4E-A006-0A64079985ED}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + appveyor.yml = appveyor.yml + build.ps1 = build.ps1 + global.json = global.json + NuGet.Config = NuGet.Config + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Actors", "src\Autofac.Integration.ServiceFabric.Actors\Autofac.Integration.ServiceFabric.Actors.csproj", "{92F547AA-A38D-44B7-B1ED-AAF42F3748A3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Services", "src\Autofac.Integration.ServiceFabric.Services\Autofac.Integration.ServiceFabric.Services.csproj", "{F76F8A9D-F1F0-4652-90A8-1D1C25657F66}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Services.Test", "test\Autofac.Integration.ServiceFabric.Services.Test\Autofac.Integration.ServiceFabric.Services.Test.csproj", "{B8F4F393-FAB8-418F-A505-6477E56A0B2D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric.Actors.Test", "test\Autofac.Integration.ServiceFabric.Actors.Test\Autofac.Integration.ServiceFabric.Actors.Test.csproj", "{1D2168A0-7D56-4A90-9C08-068571C54F23}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Autofac.Integration.ServiceFabric", "src\Autofac.Integration.ServiceFabric\Autofac.Integration.ServiceFabric.csproj", "{06F9228F-8871-4846-B3E8-966E9A410467}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4F3D8A91-2410-40B5-96E6-559360D39E6D}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Actors", "Actors", "{7180610C-3B07-45B6-BEE9-4999F24E9A3B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{0397F396-6F6A-45C7-806A-AADD6E35E579}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Scenario.InternalsVisible.Actors", "Test.Scenario.InternalsVisible.Actors\Test.Scenario.InternalsVisible.Actors.csproj", "{9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Scenario.InternalsVisible.Services", "Test.Scenario.InternalsVisible.Services\Test.Scenario.InternalsVisible.Services.csproj", "{E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|x64.ActiveCfg = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Debug|x64.Build.0 = Debug|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|Any CPU.Build.0 = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|x64.ActiveCfg = Release|Any CPU + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3}.Release|x64.Build.0 = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|x64.ActiveCfg = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Debug|x64.Build.0 = Debug|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|Any CPU.Build.0 = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|x64.ActiveCfg = Release|Any CPU + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66}.Release|x64.Build.0 = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|x64.ActiveCfg = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Debug|x64.Build.0 = Debug|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|Any CPU.Build.0 = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|x64.ActiveCfg = Release|Any CPU + {B8F4F393-FAB8-418F-A505-6477E56A0B2D}.Release|x64.Build.0 = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|x64.ActiveCfg = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Debug|x64.Build.0 = Debug|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|Any CPU.Build.0 = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|x64.ActiveCfg = Release|Any CPU + {1D2168A0-7D56-4A90-9C08-068571C54F23}.Release|x64.Build.0 = Release|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Debug|Any CPU.Build.0 = Debug|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Debug|x64.ActiveCfg = Debug|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Debug|x64.Build.0 = Debug|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Release|Any CPU.ActiveCfg = Release|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Release|Any CPU.Build.0 = Release|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Release|x64.ActiveCfg = Release|Any CPU + {06F9228F-8871-4846-B3E8-966E9A410467}.Release|x64.Build.0 = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|x64.ActiveCfg = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Debug|x64.Build.0 = Debug|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|Any CPU.Build.0 = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|x64.ActiveCfg = Release|Any CPU + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416}.Release|x64.Build.0 = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|x64.ActiveCfg = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Debug|x64.Build.0 = Debug|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|Any CPU.Build.0 = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|x64.ActiveCfg = Release|Any CPU + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA}.Release|x64.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {92F547AA-A38D-44B7-B1ED-AAF42F3748A3} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {F76F8A9D-F1F0-4652-90A8-1D1C25657F66} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + {B8F4F393-FAB8-418F-A505-6477E56A0B2D} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + {1D2168A0-7D56-4A90-9C08-068571C54F23} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {9BBA7AE1-92ED-4B55-ACA4-958E2E25A416} = {7180610C-3B07-45B6-BEE9-4999F24E9A3B} + {E6DB1CA6-8189-4D37-B41C-219B73B7C3BA} = {0397F396-6F6A-45C7-806A-AADD6E35E579} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {9C702E07-7135-47CD-9650-31EB57F0592A} + EndGlobalSection +EndGlobal diff --git a/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Actors/ActorFactoryRegistration.cs similarity index 95% rename from src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Actors/ActorFactoryRegistration.cs index 06e9104..98bff7e 100644 --- a/src/Autofac.Integration.ServiceFabric/ActorFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/ActorFactoryRegistration.cs @@ -29,7 +29,7 @@ using Microsoft.ServiceFabric.Actors; using Microsoft.ServiceFabric.Actors.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { // ReSharper disable once ClassNeverInstantiated.Global [SuppressMessage("Microsoft.Performance", "CA1812", Justification = "Instantiated at runtime via dependency injection")] @@ -51,10 +51,10 @@ public ActorFactoryRegistration( public void RegisterActorFactory( ILifetimeScope container, Type actorServiceType, - Func stateManagerFactory = null, - IActorStateProvider stateProvider = null, - ActorServiceSettings settings = null, - object lifetimeScopeTag = null) + Func? stateManagerFactory = null, + IActorStateProvider? stateProvider = null, + ActorServiceSettings? settings = null, + object? lifetimeScopeTag = null) where TActor : ActorBase { ActorRuntime.RegisterActorAsync((context, actorTypeInfo) => diff --git a/src/Autofac.Integration.ServiceFabric/ActorInterceptor.cs b/src/Autofac.Integration.ServiceFabric.Actors/ActorInterceptor.cs similarity index 97% rename from src/Autofac.Integration.ServiceFabric/ActorInterceptor.cs rename to src/Autofac.Integration.ServiceFabric.Actors/ActorInterceptor.cs index 3e7a7e1..9b2f0cd 100644 --- a/src/Autofac.Integration.ServiceFabric/ActorInterceptor.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/ActorInterceptor.cs @@ -26,7 +26,7 @@ using System.Diagnostics.CodeAnalysis; using Castle.DynamicProxy; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { [SuppressMessage("Microsoft.Performance", "CA1812", Justification = "Instantiated at runtime via dependency injection")] internal sealed class ActorInterceptor : IInterceptor diff --git a/src/Autofac.Integration.ServiceFabric/Properties/AssemblyInfo.cs b/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs similarity index 51% rename from src/Autofac.Integration.ServiceFabric/Properties/AssemblyInfo.cs rename to src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs index af74c8e..5b5d1ed 100644 --- a/src/Autofac.Integration.ServiceFabric/Properties/AssemblyInfo.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs @@ -6,6 +6,6 @@ [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] -[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001008728425885ef385e049261b18878327dfaaf0d666dea3bd2b0e4f18b33929ad4e5fbc9087e7eda3c1291d2de579206d9b4292456abffbe8be6c7060b36da0c33b883e3878eaf7c89fddf29e6e27d24588e81e86f3a22dd7b1a296b5f06fbfb500bbd7410faa7213ef4e2ce7622aefc03169b0324bcd30ccfe9ac8204e4960be6")] +[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Actors.Test")] [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] -[assembly: SuppressMessage("Microsoft.Design", "CA1020", Scope = "namespace", Target = "Autofac.Integration.ServiceFabric")] +[assembly: SuppressMessage("Microsoft.Design", "CA1020", Scope = "namespace", Target = "Autofac.Integration.ServiceFabric.Actors")] diff --git a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj b/src/Autofac.Integration.ServiceFabric.Actors/Autofac.Integration.ServiceFabric.Actors.csproj similarity index 85% rename from src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj rename to src/Autofac.Integration.ServiceFabric.Actors/Autofac.Integration.ServiceFabric.Actors.csproj index fef2af7..d3d23ea 100644 --- a/src/Autofac.Integration.ServiceFabric/Autofac.Integration.ServiceFabric.csproj +++ b/src/Autofac.Integration.ServiceFabric.Actors/Autofac.Integration.ServiceFabric.Actors.csproj @@ -1,7 +1,10 @@ - + - Autofac integration for Azure Service Fabric. Provides service factory implementations for Actors, Stateful Services and Stateless Services. + enable + enable + latest + Autofac integration for Azure Service Fabric. Provides service factory implementations for Actors. 0.0.1 netstandard2.1;netstandard2.0 @@ -10,13 +13,13 @@ $(NoWarn);CS1591 true true - Autofac.Integration.ServiceFabric - ../../Autofac.snk - true + Autofac.Integration.ServiceFabric.Actors + en-US true Copyright © 2017 Autofac Contributors - Autofac.ServiceFabric + Autofac.ServiceFabric.Actors autofac;di;ioc;dependencyinjection;servicefabric;azure Release notes are at https://github.com/autofac/Autofac.ServiceFabric/releases icon.png @@ -35,7 +38,10 @@ - + + \ + true + @@ -45,8 +51,7 @@ All - all - runtime; build; native; contentfiles; analyzers; buildtransitive + All diff --git a/src/Autofac.Integration.ServiceFabric/AutofacActorExtensions.cs b/src/Autofac.Integration.ServiceFabric.Actors/AutofacActorExtensions.cs similarity index 93% rename from src/Autofac.Integration.ServiceFabric/AutofacActorExtensions.cs rename to src/Autofac.Integration.ServiceFabric.Actors/AutofacActorExtensions.cs index f20b6b5..87222f6 100644 --- a/src/Autofac.Integration.ServiceFabric/AutofacActorExtensions.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/AutofacActorExtensions.cs @@ -27,7 +27,7 @@ using Autofac.Builder; using Microsoft.ServiceFabric.Actors.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { /// /// Extension methods for registering actors with Autofac and Service Fabric. @@ -50,11 +50,11 @@ public static class AutofacActorExtensions public static IRegistrationBuilder RegisterActor( this ContainerBuilder builder, - Type actorServiceType = null, - Func stateManagerFactory = null, - IActorStateProvider stateProvider = null, - ActorServiceSettings settings = null, - object lifetimeScopeTag = null) + Type? actorServiceType = null, + Func? stateManagerFactory = null, + IActorStateProvider? stateProvider = null, + ActorServiceSettings? settings = null, + object? lifetimeScopeTag = null) where TActor : ActorBase { if (builder == null) diff --git a/src/Autofac.Integration.ServiceFabric/Constants.cs b/src/Autofac.Integration.ServiceFabric.Actors/Constants.cs similarity index 69% rename from src/Autofac.Integration.ServiceFabric/Constants.cs rename to src/Autofac.Integration.ServiceFabric.Actors/Constants.cs index 65e7561..30a4ccd 100644 --- a/src/Autofac.Integration.ServiceFabric/Constants.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/Constants.cs @@ -1,4 +1,4 @@ -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { internal static class Constants { diff --git a/src/Autofac.Integration.ServiceFabric/IActorFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Actors/IActorFactoryRegistration.cs similarity index 84% rename from src/Autofac.Integration.ServiceFabric/IActorFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Actors/IActorFactoryRegistration.cs index 8aac4b8..535af16 100644 --- a/src/Autofac.Integration.ServiceFabric/IActorFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/IActorFactoryRegistration.cs @@ -26,17 +26,17 @@ using System; using Microsoft.ServiceFabric.Actors.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { internal interface IActorFactoryRegistration { void RegisterActorFactory( ILifetimeScope lifetimeScope, Type actorServiceType, - Func stateManagerFactory = null, - IActorStateProvider stateProvider = null, - ActorServiceSettings settings = null, - object lifetimeScopeTag = null) - where TActor : ActorBase; + Func? stateManagerFactory = null, + IActorStateProvider? stateProviders = null, + ActorServiceSettings? settings = null, + object? lifetimeScopeTag = null) + where TActor : ActorBase; } -} \ No newline at end of file +} diff --git a/src/Autofac.Integration.ServiceFabric.Actors/RegistrationExtensions.cs b/src/Autofac.Integration.ServiceFabric.Actors/RegistrationExtensions.cs new file mode 100644 index 0000000..e073ddd --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Actors/RegistrationExtensions.cs @@ -0,0 +1,116 @@ +// This software is part of the Autofac IoC container +// Copyright © 2017 Autofac Contributors +// https://autofac.org +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using Autofac.Builder; +using Autofac.Core; +using Autofac.Core.Lifetime; +using Autofac.Extras.DynamicProxy; +using Castle.DynamicProxy; +using Microsoft.ServiceFabric.Actors.Runtime; + +namespace Autofac.Integration.ServiceFabric.Actors +{ + /// + /// Adds registration syntax to the type. + /// + public static class RegistrationExtensions + { + private const string MetadataKey = "__ServiceFabricRegistered"; + + /// + /// Adds the core services required by the Service Fabric integration. + /// + /// The container builder to register the services with. + /// Callback will be invoked if an exception is thrown during resolving. + /// Callback will be invoked while configuring the lifetime scope for a service. + public static void RegisterServiceFabricSupport( + this ContainerBuilder builder, + Action? constructorExceptionCallback = null, + Action? configurationAction = null) + { + if (builder == null) throw new ArgumentNullException(nameof(builder)); + + if (builder.Properties.ContainsKey(MetadataKey)) return; + + builder.AddInternalRegistrations(constructorExceptionCallback, configurationAction); + + builder.Properties.Add(MetadataKey, true); + } + + internal static IRegistrationBuilder + RegisterServiceWithInterception( + this ContainerBuilder builder, + object? lifetimeScopeTag = null) + where TService : class + where TInterceptor : IInterceptor + { + return builder.RegisterType() + .InstancePerMatchingLifetimeScope(lifetimeScopeTag ?? Constants.DefaultLifetimeScopeTag) + .EnableClassInterceptors() + .InterceptedBy(typeof(TInterceptor)); + } + + internal static IRegistrationBuilder + EnsureRegistrationIsInstancePerLifetimeScope( + this IRegistrationBuilder builder) + where TService : class + { + return builder.OnRegistered(args => + { + var registration = args.ComponentRegistration; + + if (registration.Lifetime.GetType() == typeof(MatchingScopeLifetime) && + registration.Sharing == InstanceSharing.Shared && + registration.Ownership == InstanceOwnership.OwnedByLifetimeScope) return; + + var message = typeof(TService).GetServiceNotRegisteredAsInstancePerLifetimeScopeMessage(); + throw new InvalidOperationException(message); + }); + } + + private static void AddInternalRegistrations( + this ContainerBuilder builder, + Action? constructorExceptionCallback = null, + Action? configurationAction = null) + { + var exceptionCallback = constructorExceptionCallback ?? (ex => { }); + var configurationCallback = configurationAction ?? (_ => { }); + + builder.RegisterType() + .InstancePerLifetimeScope(); + + builder.RegisterType() + .As() + .WithParameter(TypedParameter.From(exceptionCallback)) + .WithParameter(TypedParameter.From(configurationCallback)) + .SingleInstance(); + + builder.RegisterType() + .AsSelf() + .InstancePerDependency(); + } + } +} diff --git a/src/Autofac.Integration.ServiceFabric/TypeExtensions.cs b/src/Autofac.Integration.ServiceFabric.Actors/TypeExtensions.cs similarity index 97% rename from src/Autofac.Integration.ServiceFabric/TypeExtensions.cs rename to src/Autofac.Integration.ServiceFabric.Actors/TypeExtensions.cs index b2210ee..5108141 100644 --- a/src/Autofac.Integration.ServiceFabric/TypeExtensions.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/TypeExtensions.cs @@ -27,7 +27,7 @@ using System.Globalization; using Castle.DynamicProxy; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Actors { internal static class TypeExtensions { diff --git a/src/Autofac.Integration.ServiceFabric/TypeExtensionsResources.Designer.cs b/src/Autofac.Integration.ServiceFabric.Actors/TypeExtensionsResources.Designer.cs similarity index 90% rename from src/Autofac.Integration.ServiceFabric/TypeExtensionsResources.Designer.cs rename to src/Autofac.Integration.ServiceFabric.Actors/TypeExtensionsResources.Designer.cs index e1b3c57..89c56f5 100644 --- a/src/Autofac.Integration.ServiceFabric/TypeExtensionsResources.Designer.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/TypeExtensionsResources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Autofac.Integration.ServiceFabric { +namespace Autofac.Integration.ServiceFabric.Actors { using System; @@ -19,7 +19,7 @@ namespace Autofac.Integration.ServiceFabric { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class TypeExtensionsResources { @@ -39,7 +39,7 @@ internal TypeExtensionsResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.ServiceFabric.TypeExtensionsResources", typeof(TypeExtensionsResources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.ServiceFabric.Actors.TypeExtensionsResources", typeof(TypeExtensionsResources).Assembly); resourceMan = temp; } return resourceMan; @@ -60,6 +60,15 @@ internal TypeExtensionsResources() { } } + /// + /// Looks up a localized string similar to The type {0} need to be inherited from ActorService.. + /// + internal static string InvalidActorServiceTypeErrorMessage { + get { + return ResourceManager.GetString("InvalidActorServiceTypeErrorMessage", resourceCulture); + } + } + /// /// Looks up a localized string similar to The type {0} cannot be dynamically proxied. Service types must not be sealed and need to be visible to the DynamicProxyGenAssembly2 assembly. This can be achieved by making the type public or adding the InternalsVisibleToAttribute to the assembly containing the type. e.g. [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)]. /// @@ -77,12 +86,5 @@ internal static string ServiceNotRegisteredAsIntancePerLifetimeScope { return ResourceManager.GetString("ServiceNotRegisteredAsIntancePerLifetimeScope", resourceCulture); } } - - internal static string InvalidActorServiceTypeErrorMessage { - get - { - return ResourceManager.GetString("InvalidActorServiceTypeErrorMessage", resourceCulture); - } - } } } diff --git a/src/Autofac.Integration.ServiceFabric/TypeExtensionsResources.resx b/src/Autofac.Integration.ServiceFabric.Actors/TypeExtensionsResources.resx similarity index 100% rename from src/Autofac.Integration.ServiceFabric/TypeExtensionsResources.resx rename to src/Autofac.Integration.ServiceFabric.Actors/TypeExtensionsResources.resx diff --git a/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs b/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs new file mode 100644 index 0000000..aa8c6b3 --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs @@ -0,0 +1,11 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using Castle.Core.Internal; + +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Services.Test")] +[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] +[assembly: SuppressMessage("Microsoft.Design", "CA1020", Scope = "namespace", Target = "Autofac.Integration.ServiceFabric.Services")] diff --git a/src/Autofac.Integration.ServiceFabric.Services/Autofac.Integration.ServiceFabric.Services.csproj b/src/Autofac.Integration.ServiceFabric.Services/Autofac.Integration.ServiceFabric.Services.csproj new file mode 100644 index 0000000..3506134 --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/Autofac.Integration.ServiceFabric.Services.csproj @@ -0,0 +1,91 @@ + + + + netstandard2.1;netstandard2.0 + enable + latest + enable + Autofac integration for Azure Service Fabric. Provides service factory implementations for Stateful and Stateless Services. + + 0.0.1 + latest + x64 + $(NoWarn);CS1591 + true + true + Autofac.Integration.ServiceFabric.Services + + en-US + true + Copyright © 2017 Autofac Contributors + Autofac.ServiceFabric.Actors + autofac;di;ioc;dependencyinjection;servicefabric;azure + Release notes are at https://github.com/autofac/Autofac.ServiceFabric/releases + icon.png + https://autofac.org + MIT + git + https://github.com/autofac/Autofac.ServiceFabric + true + true + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + ../../build/Analyzers.ruleset + IOperation + Autofac Contributors + Autofac + Autofac + + + + + \ + true + + + + + + + + All + + + All + + + + + + All + + + All + + + + + + True + True + AutofacServiceExtensionsResources.resx + + + True + True + TypeExtensionsResources.resx + + + + + + ResXFileCodeGenerator + AutofacServiceExtensionsResources.Designer.cs + + + ResXFileCodeGenerator + TypeExtensionsResources.Designer.cs + + + + diff --git a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensions.cs b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensions.cs similarity index 96% rename from src/Autofac.Integration.ServiceFabric/AutofacServiceExtensions.cs rename to src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensions.cs index 45ba1d3..f456820 100644 --- a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensions.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensions.cs @@ -27,7 +27,7 @@ using Autofac.Builder; using Microsoft.ServiceFabric.Services.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { /// /// Extension methods for registering services (stateful and stateless) with Autofac and Service Fabric. @@ -48,7 +48,7 @@ public static IRegistrationBuilder( this ContainerBuilder builder, string serviceTypeName, - object lifetimeScopeTag = null) + object? lifetimeScopeTag = null) where TService : StatefulServiceBase { var registration = RegisterServiceWithContainer(builder, serviceTypeName, lifetimeScopeTag); @@ -74,7 +74,7 @@ public static IRegistrationBuilder( this ContainerBuilder builder, string serviceTypeName, - object lifetimeScopeTag = null) + object? lifetimeScopeTag = null) where TService : StatelessService { var registration = RegisterServiceWithContainer(builder, serviceTypeName, lifetimeScopeTag); @@ -90,7 +90,7 @@ private static IRegistrationBuilder( ContainerBuilder builder, string serviceTypeName, - object lifetimeScopeTag = null) + object? lifetimeScopeTag = null) where TService : class { if (builder == null) diff --git a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.Designer.cs b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.Designer.cs similarity index 92% rename from src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.Designer.cs rename to src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.Designer.cs index 31c1789..72f3393 100644 --- a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.Designer.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Autofac.Integration.ServiceFabric { +namespace Autofac.Integration.ServiceFabric.Services { using System; @@ -19,7 +19,7 @@ namespace Autofac.Integration.ServiceFabric { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class AutofacServiceExtensionsResources { @@ -39,7 +39,7 @@ internal AutofacServiceExtensionsResources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.ServiceFabric.AutofacServiceExtensionsResources", typeof(AutofacServiceExtensionsResources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.ServiceFabric.Services.AutofacServiceExtensionsResources", typeof(AutofacServiceExtensionsResources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.resx b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.resx similarity index 99% rename from src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.resx rename to src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.resx index 5c9f11a..6094d6e 100644 --- a/src/Autofac.Integration.ServiceFabric/AutofacServiceExtensionsResources.resx +++ b/src/Autofac.Integration.ServiceFabric.Services/AutofacServiceExtensionsResources.resx @@ -53,7 +53,6 @@ value : The object must be serialized with : System.Runtime.Serialization.Formatters.Soap.SoapFormatter : and then encoded with base64 encoding. - mimetype: application/x-microsoft.net.object.bytearray.base64 value : The object must be serialized into a byte array : using a System.ComponentModel.TypeConverter @@ -120,4 +119,4 @@ The service type name must be provided - \ No newline at end of file + diff --git a/src/Autofac.Integration.ServiceFabric.Services/Constants.cs b/src/Autofac.Integration.ServiceFabric.Services/Constants.cs new file mode 100644 index 0000000..169e623 --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/Constants.cs @@ -0,0 +1,7 @@ +namespace Autofac.Integration.ServiceFabric.Services +{ + internal static class Constants + { + internal const string DefaultLifetimeScopeTag = "ServiceFabric"; + } +} diff --git a/src/Autofac.Integration.ServiceFabric/IStatefulServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Services/IStatefulServiceFactoryRegistration.cs similarity index 82% rename from src/Autofac.Integration.ServiceFabric/IStatefulServiceFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Services/IStatefulServiceFactoryRegistration.cs index 60cacdc..14244f1 100644 --- a/src/Autofac.Integration.ServiceFabric/IStatefulServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/IStatefulServiceFactoryRegistration.cs @@ -1,5 +1,5 @@ -// This software is part of the Autofac IoC container -// Copyright © 2017 Autofac Contributors +// This software is part of the Autofac IoC container +// Copyright © 2017 Autofac Contributors // https://autofac.org // // Permission is hereby granted, free of charge, to any person @@ -25,12 +25,14 @@ using Microsoft.ServiceFabric.Services.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { internal interface IStatefulServiceFactoryRegistration { void RegisterStatefulServiceFactory( - ILifetimeScope lifetimeScope, string serviceTypeName, object lifetimeScopeTag = null) + ILifetimeScope lifetimeScope, + string serviceTypeName, + object? lifetimeScopeTag = null) where TService : StatefulServiceBase; } -} \ No newline at end of file +} diff --git a/src/Autofac.Integration.ServiceFabric/IStatelessServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Services/IStatelessServiceFactoryRegistration.cs similarity index 82% rename from src/Autofac.Integration.ServiceFabric/IStatelessServiceFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Services/IStatelessServiceFactoryRegistration.cs index 8d12ce2..9bdc533 100644 --- a/src/Autofac.Integration.ServiceFabric/IStatelessServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/IStatelessServiceFactoryRegistration.cs @@ -1,5 +1,5 @@ -// This software is part of the Autofac IoC container -// Copyright © 2017 Autofac Contributors +// This software is part of the Autofac IoC container +// Copyright © 2017 Autofac Contributors // https://autofac.org // // Permission is hereby granted, free of charge, to any person @@ -25,12 +25,14 @@ using Microsoft.ServiceFabric.Services.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { internal interface IStatelessServiceFactoryRegistration { void RegisterStatelessServiceFactory( - ILifetimeScope lifetimeScope, string serviceTypeName, object lifetimeScopeTag = null) + ILifetimeScope lifetimeScope, + string serviceTypeName, + object? lifetimeScopeTag = null) where TService : StatelessService; } -} \ No newline at end of file +} diff --git a/src/Autofac.Integration.ServiceFabric/RegistrationExtensions.cs b/src/Autofac.Integration.ServiceFabric.Services/RegistrationExtensions.cs similarity index 84% rename from src/Autofac.Integration.ServiceFabric/RegistrationExtensions.cs rename to src/Autofac.Integration.ServiceFabric.Services/RegistrationExtensions.cs index 8ce4915..4e4538d 100644 --- a/src/Autofac.Integration.ServiceFabric/RegistrationExtensions.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/RegistrationExtensions.cs @@ -29,9 +29,8 @@ using Autofac.Core.Lifetime; using Autofac.Extras.DynamicProxy; using Castle.DynamicProxy; -using Microsoft.ServiceFabric.Actors.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { /// /// Adds registration syntax to the type. @@ -48,8 +47,8 @@ public static class RegistrationExtensions /// Callback will be invoked while configuring the lifetime scope for a service. public static void RegisterServiceFabricSupport( this ContainerBuilder builder, - Action constructorExceptionCallback = null, - Action configurationAction = null) + Action? constructorExceptionCallback = null, + Action? configurationAction = null) { if (builder == null) throw new ArgumentNullException(nameof(builder)); @@ -63,7 +62,7 @@ public static void RegisterServiceFabricSupport( internal static IRegistrationBuilder RegisterServiceWithInterception( this ContainerBuilder builder, - object lifetimeScopeTag = null) + object? lifetimeScopeTag = null) where TService : class where TInterceptor : IInterceptor { @@ -93,24 +92,15 @@ internal static IRegistrationBuilder constructorExceptionCallback = null, - Action configurationAction = null) + Action? constructorExceptionCallback = null, + Action? configurationAction = null) { var exceptionCallback = constructorExceptionCallback ?? (ex => { }); var configurationCallback = configurationAction ?? (_ => { }); - builder.RegisterType() - .InstancePerLifetimeScope(); - builder.RegisterType() .InstancePerLifetimeScope(); - builder.RegisterType() - .As() - .WithParameter(TypedParameter.From(exceptionCallback)) - .WithParameter(TypedParameter.From(configurationCallback)) - .SingleInstance(); - builder.RegisterType() .As() .WithParameter(TypedParameter.From(exceptionCallback)) @@ -122,10 +112,6 @@ private static void AddInternalRegistrations( .WithParameter(TypedParameter.From(exceptionCallback)) .WithParameter(TypedParameter.From(configurationCallback)) .SingleInstance(); - - builder.RegisterType() - .AsSelf() - .InstancePerDependency(); } } } diff --git a/src/Autofac.Integration.ServiceFabric/ServiceInterceptor.cs b/src/Autofac.Integration.ServiceFabric.Services/ServiceInterceptor.cs similarity index 97% rename from src/Autofac.Integration.ServiceFabric/ServiceInterceptor.cs rename to src/Autofac.Integration.ServiceFabric.Services/ServiceInterceptor.cs index 006e072..be2d8d1 100644 --- a/src/Autofac.Integration.ServiceFabric/ServiceInterceptor.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/ServiceInterceptor.cs @@ -26,7 +26,7 @@ using System.Diagnostics.CodeAnalysis; using Castle.DynamicProxy; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { [SuppressMessage("Microsoft.Performance", "CA1812", Justification = "Instantiated at runtime via dependency injection")] internal sealed class ServiceInterceptor : IInterceptor diff --git a/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Services/StatefulServiceFactoryRegistration.cs similarity index 95% rename from src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Services/StatefulServiceFactoryRegistration.cs index 85fdd3d..aade57c 100644 --- a/src/Autofac.Integration.ServiceFabric/StatefulServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/StatefulServiceFactoryRegistration.cs @@ -28,7 +28,7 @@ using System.Fabric; using Microsoft.ServiceFabric.Services.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { // ReSharper disable once ClassNeverInstantiated.Global [SuppressMessage("Microsoft.Performance", "CA1812", Justification = "Instantiated at runtime via dependency injection")] @@ -48,7 +48,9 @@ public StatefulServiceFactoryRegistration( } public void RegisterStatefulServiceFactory( - ILifetimeScope container, string serviceTypeName, object lifetimeScopeTag = null) + ILifetimeScope container, + string serviceTypeName, + object? lifetimeScopeTag = null) where TService : StatefulServiceBase { ServiceRuntime.RegisterServiceAsync(serviceTypeName, context => diff --git a/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs b/src/Autofac.Integration.ServiceFabric.Services/StatelessServiceFactoryRegistration.cs similarity index 95% rename from src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs rename to src/Autofac.Integration.ServiceFabric.Services/StatelessServiceFactoryRegistration.cs index f245b59..a9ce62a 100644 --- a/src/Autofac.Integration.ServiceFabric/StatelessServiceFactoryRegistration.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/StatelessServiceFactoryRegistration.cs @@ -28,7 +28,7 @@ using System.Fabric; using Microsoft.ServiceFabric.Services.Runtime; -namespace Autofac.Integration.ServiceFabric +namespace Autofac.Integration.ServiceFabric.Services { // ReSharper disable once ClassNeverInstantiated.Global [SuppressMessage("Microsoft.Performance", "CA1812", Justification = "Instantiated at runtime via dependency injection")] @@ -48,7 +48,9 @@ public StatelessServiceFactoryRegistration( } public void RegisterStatelessServiceFactory( - ILifetimeScope container, string serviceTypeName, object lifetimeScopeTag = null) + ILifetimeScope container, + string serviceTypeName, + object? lifetimeScopeTag = null) where TService : StatelessService { ServiceRuntime.RegisterServiceAsync(serviceTypeName, context => diff --git a/src/Autofac.Integration.ServiceFabric.Services/TypeExtensions.cs b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensions.cs new file mode 100644 index 0000000..0dea19c --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensions.cs @@ -0,0 +1,56 @@ +// This software is part of the Autofac IoC container +// Copyright © 2017 Autofac Contributors +// https://autofac.org +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. + +using System; +using System.Globalization; +using Castle.DynamicProxy; + +namespace Autofac.Integration.ServiceFabric.Services +{ + internal static class TypeExtensions + { + internal static bool CanBeProxied(this Type type) + { + var open = type.IsClass && !type.IsSealed && !type.IsAbstract; + var visible = type.IsPublic || ProxyUtil.IsAccessible(type); + return open && visible; + } + + internal static string GetInvalidProxyTypeErrorMessage(this Type type) + { + return string.Format(CultureInfo.CurrentCulture, TypeExtensionsResources.InvalidProxyTypeErrorMessage, type.FullName); + } + + internal static string GetServiceNotRegisteredAsInstancePerLifetimeScopeMessage(this Type type) + { + return string.Format(CultureInfo.CurrentCulture, TypeExtensionsResources.ServiceNotRegisteredAsIntancePerLifetimeScope, type.FullName); + } + + internal static string GetInvalidActorServiceTypeErrorMessage(this Type type) + { + return string.Format(CultureInfo.CurrentCulture, TypeExtensionsResources.InvalidActorServiceTypeErrorMessage, type.FullName); + } + } +} diff --git a/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.Designer.cs b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.Designer.cs new file mode 100644 index 0000000..17b81ee --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.Designer.cs @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Autofac.Integration.ServiceFabric.Services { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class TypeExtensionsResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal TypeExtensionsResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Autofac.Integration.ServiceFabric.Services.TypeExtensionsResources", typeof(TypeExtensionsResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to The type {0} need to be inherited from ActorService.. + /// + internal static string InvalidActorServiceTypeErrorMessage { + get { + return ResourceManager.GetString("InvalidActorServiceTypeErrorMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The type {0} cannot be dynamically proxied. Service types must not be sealed and need to be visible to the DynamicProxyGenAssembly2 assembly. This can be achieved by making the type public or adding the InternalsVisibleToAttribute to the assembly containing the type. e.g. [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)]. + /// + internal static string InvalidProxyTypeErrorMessage { + get { + return ResourceManager.GetString("InvalidProxyTypeErrorMessage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The service {0} must be registered as InstancePerLifetimeScope.. + /// + internal static string ServiceNotRegisteredAsIntancePerLifetimeScope { + get { + return ResourceManager.GetString("ServiceNotRegisteredAsIntancePerLifetimeScope", resourceCulture); + } + } + } +} diff --git a/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.resx b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.resx new file mode 100644 index 0000000..9a85758 --- /dev/null +++ b/src/Autofac.Integration.ServiceFabric.Services/TypeExtensionsResources.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + The type {0} cannot be dynamically proxied. Service types must not be sealed and need to be visible to the DynamicProxyGenAssembly2 assembly. This can be achieved by making the type public or adding the InternalsVisibleToAttribute to the assembly containing the type. e.g. [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] + + + The service {0} must be registered as InstancePerLifetimeScope. + + + The type {0} need to be inherited from ActorService. + + \ No newline at end of file diff --git a/test/Autofac.Integration.ServiceFabric.Test/ActorInterceptorTests.cs b/test/Autofac.Integration.ServiceFabric.Actors.Test/ActorInterceptorTests.cs similarity index 93% rename from test/Autofac.Integration.ServiceFabric.Test/ActorInterceptorTests.cs rename to test/Autofac.Integration.ServiceFabric.Actors.Test/ActorInterceptorTests.cs index 57fbd70..ad26c6a 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/ActorInterceptorTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/ActorInterceptorTests.cs @@ -2,7 +2,7 @@ using Xunit; using IInvocation = Castle.DynamicProxy.IInvocation; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Actors.Test { public sealed class ActorInterceptorTests { diff --git a/test/Autofac.Integration.ServiceFabric.Test/Assertions.cs b/test/Autofac.Integration.ServiceFabric.Actors.Test/Assertions.cs similarity index 95% rename from test/Autofac.Integration.ServiceFabric.Test/Assertions.cs rename to test/Autofac.Integration.ServiceFabric.Actors.Test/Assertions.cs index 31f8e10..354cd65 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/Assertions.cs +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/Assertions.cs @@ -1,7 +1,7 @@ using Autofac.Core; using Xunit; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Actors.Test { internal static class Assertions { diff --git a/test/Autofac.Integration.ServiceFabric.Actors.Test/Autofac.Integration.ServiceFabric.Actors.Test.csproj b/test/Autofac.Integration.ServiceFabric.Actors.Test/Autofac.Integration.ServiceFabric.Actors.Test.csproj new file mode 100644 index 0000000..92eac7f --- /dev/null +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/Autofac.Integration.ServiceFabric.Actors.Test.csproj @@ -0,0 +1,45 @@ + + + + enable + enable + false + latest + netcoreapp3.1 + x64 + $(NoWarn);CS1591;SA1602;SA1611;SA1402 + true + + + + ../../build/Analyzers.ruleset + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers + + + All + + + + + + + + + + + diff --git a/test/Autofac.Integration.ServiceFabric.Test/AutofacActorExtensionsTests.cs b/test/Autofac.Integration.ServiceFabric.Actors.Test/AutofacActorExtensionsTests.cs similarity index 99% rename from test/Autofac.Integration.ServiceFabric.Test/AutofacActorExtensionsTests.cs rename to test/Autofac.Integration.ServiceFabric.Actors.Test/AutofacActorExtensionsTests.cs index 4d55fb8..1b90253 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/AutofacActorExtensionsTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/AutofacActorExtensionsTests.cs @@ -5,10 +5,10 @@ using Microsoft.ServiceFabric.Actors; using Microsoft.ServiceFabric.Actors.Runtime; using Moq; -using Test.Scenario.InternalsVisible; +using Test.Scenario.InternalsVisible.Actors; using Xunit; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Actors.Test { public sealed class AutofacActorExtensionsTests { diff --git a/test/Autofac.Integration.ServiceFabric.Actors.Test/RegistrationExtensionsTests.cs b/test/Autofac.Integration.ServiceFabric.Actors.Test/RegistrationExtensionsTests.cs new file mode 100644 index 0000000..3eacb6f --- /dev/null +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/RegistrationExtensionsTests.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace Autofac.Integration.ServiceFabric.Actors.Test +{ + public sealed class RegistrationExtensionsTests + { + [Fact] + public void RegisterServiceFabricSupportOnlyAddsModuleOnce() + { + var builder = new ContainerBuilder(); + builder.RegisterServiceFabricSupport(); + builder.RegisterServiceFabricSupport(); + + var container = builder.Build(); + + var actorInterceptors = container.Resolve>().ToArray(); + Assert.Single(actorInterceptors); + } + + [Fact] + public void RegisterServiceFabricSupportThrowsWhenContainerBuilderIsNull() + { + var exception = Assert.Throws(() => RegistrationExtensions.RegisterServiceFabricSupport(null)); + + Assert.Equal("builder", exception.ParamName); + } + } +} diff --git a/test/Autofac.Integration.ServiceFabric.Actors.Test/ServiceFabricModuleTests.cs b/test/Autofac.Integration.ServiceFabric.Actors.Test/ServiceFabricModuleTests.cs new file mode 100644 index 0000000..766dacc --- /dev/null +++ b/test/Autofac.Integration.ServiceFabric.Actors.Test/ServiceFabricModuleTests.cs @@ -0,0 +1,72 @@ +using System; +using Xunit; + +namespace Autofac.Integration.ServiceFabric.Actors.Test +{ + public sealed class ServiceFabricModuleTests + { + [Theory] + [InlineData(typeof(ActorInterceptor))] + [InlineData(typeof(IActorFactoryRegistration))] + public void RegistersRequiredSupportTypes(Type interceptorType) + { + var builder = new ContainerBuilder(); + builder.RegisterServiceFabricSupport(); + var container = builder.Build(); + + Assert.True(container.IsRegistered(interceptorType)); + } + + [Fact] + public void ActorFactoryRegistrationReceivesProvidedConstructorExceptionCallbackParameter() + { + var builder = new ContainerBuilder(); + Exception capturedException = null; + void ConstructorExceptionCallback(Exception ex) => capturedException = ex; + builder.RegisterServiceFabricSupport(ConstructorExceptionCallback); + var container = builder.Build(); + + var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); + var thrownException = new Exception("Failed to construct instance"); + factoryRegistration.ConstructorExceptionCallback(thrownException); + + Assert.Same(thrownException, capturedException); + } + + [Fact] + public void ActorFactoryRegistrationReceivesDefaultConstructorExceptionCallbackParameter() + { + var builder = new ContainerBuilder(); + builder.RegisterServiceFabricSupport(); + var container = builder.Build(); + + var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); + Assert.NotNull(factoryRegistration.ConstructorExceptionCallback); + } + + [Fact] + public void ActorFactoryRegistrationReceivesProvidedConfigurationActionParameter() + { + var builder = new ContainerBuilder(); + var invoked = false; + builder.RegisterServiceFabricSupport(configurationAction: _ => invoked = true); + var container = builder.Build(); + + var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); + factoryRegistration.ConfigurationAction(new ContainerBuilder()); + + Assert.True(invoked); + } + + [Fact] + public void ActorFactoryRegistrationReceivesDefaultConfigurationActionParameter() + { + var builder = new ContainerBuilder(); + builder.RegisterServiceFabricSupport(); + var container = builder.Build(); + + var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); + Assert.NotNull(factoryRegistration.ConfigurationAction); + } + } +} diff --git a/test/Autofac.Integration.ServiceFabric.Services.Test/Assertions.cs b/test/Autofac.Integration.ServiceFabric.Services.Test/Assertions.cs new file mode 100644 index 0000000..92e637d --- /dev/null +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/Assertions.cs @@ -0,0 +1,37 @@ +using Autofac.Core; +using Xunit; + +namespace Autofac.Integration.ServiceFabric.Services.Test +{ + internal static class Assertions + { + internal static void AssertRegistered(this IComponentContext context) + { + Assert.True(context.IsRegistered()); + } + + internal static void AssertSharing(this IComponentContext context, InstanceSharing sharing) + { + var registration = context.RegistrationFor(); + Assert.Equal(sharing, registration.Sharing); + } + + internal static void AssertLifetime(this IComponentContext context) + { + var registration = context.RegistrationFor(); + Assert.IsType(registration.Lifetime); + } + + internal static void AssertOwnership(this IComponentContext context, InstanceOwnership ownership) + { + var registration = context.RegistrationFor(); + Assert.Equal(ownership, registration.Ownership); + } + + internal static IComponentRegistration RegistrationFor(this IComponentContext context) + { + Assert.True(context.ComponentRegistry.TryGetRegistration(new TypedService(typeof(TComponent)), out var registration)); + return registration; + } + } +} diff --git a/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj b/test/Autofac.Integration.ServiceFabric.Services.Test/Autofac.Integration.ServiceFabric.Services.Test.csproj similarity index 64% rename from test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj rename to test/Autofac.Integration.ServiceFabric.Services.Test/Autofac.Integration.ServiceFabric.Services.Test.csproj index 43fc169..a4944ac 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/Autofac.Integration.ServiceFabric.Test.csproj +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/Autofac.Integration.ServiceFabric.Services.Test.csproj @@ -1,15 +1,18 @@  + enable + enable + latest + false netcoreapp3.1 x64 $(NoWarn);CS1591;SA1602;SA1611;SA1402 true - ../../Autofac.snk - true - true + + + ../../build/Analyzers.ruleset - x64 @@ -20,6 +23,7 @@ + @@ -32,8 +36,9 @@ - - + + + - \ No newline at end of file + diff --git a/test/Autofac.Integration.ServiceFabric.Test/AutofacServiceExtensionsTests.cs b/test/Autofac.Integration.ServiceFabric.Services.Test/AutofacServiceExtensionsTests.cs similarity index 90% rename from test/Autofac.Integration.ServiceFabric.Test/AutofacServiceExtensionsTests.cs rename to test/Autofac.Integration.ServiceFabric.Services.Test/AutofacServiceExtensionsTests.cs index b845bd1..d6f452a 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/AutofacServiceExtensionsTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/AutofacServiceExtensionsTests.cs @@ -1,15 +1,19 @@ using System; using System.Collections.Generic; using System.Fabric; +using System.Fabric.Query; +using System.Linq; using Autofac.Core; using Autofac.Core.Lifetime; using Microsoft.ServiceFabric.Data; using Microsoft.ServiceFabric.Services.Runtime; using Moq; -using Test.Scenario.InternalsVisible; +using Test.Scenario.InternalsVisible.Services; using Xunit; +using Service = System.Fabric.Query.Service; +using StatelessService = Microsoft.ServiceFabric.Services.Runtime.StatelessService; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Services.Test { public sealed class AutofacServiceExtensionsTests { @@ -37,37 +41,41 @@ public void RegisterStatelessServiceRegistersProvidedType() container.AssertRegistered(); } - [Fact] - public void RegisterStatefulServiceAppliesInterceptor() - { - var builder = new ContainerBuilder(); - builder.RegisterStatefulService("ServiceType"); - builder.RegisterServiceFabricSupport(); - builder.RegisterInstance(new Mock().Object); + //[Fact] + //public void RegisterStatefulServiceAppliesInterceptor() + //{ + // var builder = new ContainerBuilder(); + // builder.RegisterStatefulService("ServiceType"); + // builder.RegisterServiceFabricSupport(); + // builder.RegisterInstance(new Mock().Object); - var container = builder.Build(); + // var container = builder.Build(); - var registration = container.RegistrationFor(); - const string metadataKey = "Autofac.Extras.DynamicProxy.RegistrationExtensions.InterceptorsPropertyName"; - var interceptorServices = (IEnumerable)registration.Metadata[metadataKey]; - Assert.Contains(new TypedService(typeof(ServiceInterceptor)), interceptorServices); - } + // var registration = container.RegistrationFor(); + // const string metadataKey = "Autofac.Extras.DynamicProxy.RegistrationExtensions.InterceptorsPropertyName"; + // var interceptorServices = (IEnumerable?)registration.Metadata[metadataKey]; + // Assert.NotNull(interceptorServices); + // Assert.Contains(new TypedService(typeof(ServiceInterceptor)), (IEnumerable)interceptorServices); + //} - [Fact] - public void RegisterStatelessServiceAppliesInterceptor() - { - var builder = new ContainerBuilder(); - builder.RegisterStatelessService("ServiceType"); - builder.RegisterServiceFabricSupport(); - builder.RegisterInstance(new Mock().Object); + //[Fact] + //public void RegisterStatelessServiceAppliesInterceptor() + //{ + // var builder = new ContainerBuilder(); + // builder.RegisterStatelessService("ServiceType"); + // builder.RegisterServiceFabricSupport(); + // builder.RegisterInstance(new Mock().Object); - var container = builder.Build(); + // var container = builder.Build(); - var registration = container.RegistrationFor(); - const string metadataKey = "Autofac.Extras.DynamicProxy.RegistrationExtensions.InterceptorsPropertyName"; - var interceptorServices = (IEnumerable)registration.Metadata[metadataKey]; - Assert.Contains(new TypedService(typeof(ServiceInterceptor)), interceptorServices); - } + // var registration = container.RegistrationFor(); + // const string metadataKey = "Autofac.Extras.DynamicProxy.RegistrationExtensions.InterceptorsPropertyName"; + // var interceptorServices = (IEnumerable)registration.Metadata[metadataKey]; + + // var result = interceptorServices.Contains(new TypedService(typeof(ServiceInterceptor))); + + // Assert.Contains(new TypedService(typeof(ServiceInterceptor)), interceptorServices); + //} [Fact] public void RegisterStatefulServiceWithoutTagRegistersInstancePerMatchingLifetimeScope() diff --git a/test/Autofac.Integration.ServiceFabric.Test/RegistrationExtensionsTests.cs b/test/Autofac.Integration.ServiceFabric.Services.Test/RegistrationExtensionsTests.cs similarity index 82% rename from test/Autofac.Integration.ServiceFabric.Test/RegistrationExtensionsTests.cs rename to test/Autofac.Integration.ServiceFabric.Services.Test/RegistrationExtensionsTests.cs index 15808ec..62c0c1e 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/RegistrationExtensionsTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/RegistrationExtensionsTests.cs @@ -1,10 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; - using Xunit; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Services.Test { public sealed class RegistrationExtensionsTests { @@ -16,10 +15,7 @@ public void RegisterServiceFabricSupportOnlyAddsModuleOnce() builder.RegisterServiceFabricSupport(); var container = builder.Build(); - - var actorInterceptors = container.Resolve>().ToArray(); - Assert.Single(actorInterceptors); - + var serviceInterceptors = container.Resolve>().ToArray(); Assert.Single(serviceInterceptors); } diff --git a/test/Autofac.Integration.ServiceFabric.Test/ServiceFabricModuleTests.cs b/test/Autofac.Integration.ServiceFabric.Services.Test/ServiceFabricModuleTests.cs similarity index 68% rename from test/Autofac.Integration.ServiceFabric.Test/ServiceFabricModuleTests.cs rename to test/Autofac.Integration.ServiceFabric.Services.Test/ServiceFabricModuleTests.cs index 88dbd70..6f145dd 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/ServiceFabricModuleTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/ServiceFabricModuleTests.cs @@ -1,14 +1,16 @@ using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; using Xunit; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Services.Test { public sealed class ServiceFabricModuleTests { [Theory] - [InlineData(typeof(ActorInterceptor))] [InlineData(typeof(ServiceInterceptor))] - [InlineData(typeof(IActorFactoryRegistration))] [InlineData(typeof(IStatefulServiceFactoryRegistration))] [InlineData(typeof(IStatelessServiceFactoryRegistration))] public void RegistersRequiredSupportTypes(Type interceptorType) @@ -19,59 +21,7 @@ public void RegistersRequiredSupportTypes(Type interceptorType) Assert.True(container.IsRegistered(interceptorType)); } - - [Fact] - public void ActorFactoryRegistrationReceivesProvidedConstructorExceptionCallbackParameter() - { - var builder = new ContainerBuilder(); - Exception capturedException = null; - void ConstructorExceptionCallback(Exception ex) => capturedException = ex; - builder.RegisterServiceFabricSupport(ConstructorExceptionCallback); - var container = builder.Build(); - - var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); - var thrownException = new Exception("Failed to construct instance"); - factoryRegistration.ConstructorExceptionCallback(thrownException); - - Assert.Same(thrownException, capturedException); - } - - [Fact] - public void ActorFactoryRegistrationReceivesDefaultConstructorExceptionCallbackParameter() - { - var builder = new ContainerBuilder(); - builder.RegisterServiceFabricSupport(); - var container = builder.Build(); - - var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); - Assert.NotNull(factoryRegistration.ConstructorExceptionCallback); - } - - [Fact] - public void ActorFactoryRegistrationReceivesProvidedConfigurationActionParameter() - { - var builder = new ContainerBuilder(); - var invoked = false; - builder.RegisterServiceFabricSupport(configurationAction: _ => invoked = true); - var container = builder.Build(); - - var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); - factoryRegistration.ConfigurationAction(new ContainerBuilder()); - - Assert.True(invoked); - } - - [Fact] - public void ActorFactoryRegistrationReceivesDefaultConfigurationActionParameter() - { - var builder = new ContainerBuilder(); - builder.RegisterServiceFabricSupport(); - var container = builder.Build(); - - var factoryRegistration = (ActorFactoryRegistration)container.Resolve(); - Assert.NotNull(factoryRegistration.ConfigurationAction); - } - + [Fact] public void StatefulServiceFactoryRegistrationReceivesProvidedConstructorExceptionCallbackParameter() { diff --git a/test/Autofac.Integration.ServiceFabric.Test/ServiceInterceptorTests.cs b/test/Autofac.Integration.ServiceFabric.Services.Test/ServiceInterceptorTests.cs similarity index 93% rename from test/Autofac.Integration.ServiceFabric.Test/ServiceInterceptorTests.cs rename to test/Autofac.Integration.ServiceFabric.Services.Test/ServiceInterceptorTests.cs index c933c74..5b61551 100644 --- a/test/Autofac.Integration.ServiceFabric.Test/ServiceInterceptorTests.cs +++ b/test/Autofac.Integration.ServiceFabric.Services.Test/ServiceInterceptorTests.cs @@ -2,7 +2,7 @@ using Xunit; using IInvocation = Castle.DynamicProxy.IInvocation; -namespace Autofac.Integration.ServiceFabric.Test +namespace Autofac.Integration.ServiceFabric.Services.Test { public sealed class ServiceInterceptorTests { diff --git a/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs b/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs new file mode 100644 index 0000000..2d3ae12 --- /dev/null +++ b/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using Castle.Core.Internal; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Actors.Test")] +[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] diff --git a/test/Test.Scenario.InternalsVisible/InternalsVisibleActor.cs b/test/Test.Scenario.InternalsVisible.Actors/InternalsVisibleActor.cs similarity index 87% rename from test/Test.Scenario.InternalsVisible/InternalsVisibleActor.cs rename to test/Test.Scenario.InternalsVisible.Actors/InternalsVisibleActor.cs index da6d823..e46a7a7 100644 --- a/test/Test.Scenario.InternalsVisible/InternalsVisibleActor.cs +++ b/test/Test.Scenario.InternalsVisible.Actors/InternalsVisibleActor.cs @@ -1,7 +1,7 @@ using Microsoft.ServiceFabric.Actors; using Microsoft.ServiceFabric.Actors.Runtime; -namespace Test.Scenario.InternalsVisible +namespace Test.Scenario.InternalsVisible.Actors { // ReSharper disable once UnusedMember.Global internal class InternalsVisibleActor : Actor diff --git a/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj b/test/Test.Scenario.InternalsVisible.Actors/Test.Scenario.InternalsVisible.Actors.csproj similarity index 53% rename from test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj rename to test/Test.Scenario.InternalsVisible.Actors/Test.Scenario.InternalsVisible.Actors.csproj index 2c8e194..27144c9 100644 --- a/test/Test.Scenario.InternalsVisible/Test.Scenario.InternalsVisible.csproj +++ b/test/Test.Scenario.InternalsVisible.Actors/Test.Scenario.InternalsVisible.Actors.csproj @@ -1,19 +1,19 @@  - netstandard2.1;netstandard2.0;net472 - x64 - ../../Autofac.snk - true + netcoreapp3.1 + enable + latest + enable true - - - - - + + + + + - \ No newline at end of file + diff --git a/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs b/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs new file mode 100644 index 0000000..e4d4730 --- /dev/null +++ b/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs @@ -0,0 +1,5 @@ +using System.Runtime.CompilerServices; +using Castle.Core.Internal; + +[assembly:InternalsVisibleTo("Autofac.Integration.ServiceFabric.Services.Test")] +[assembly:InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] diff --git a/test/Test.Scenario.InternalsVisible/InternalsVisibleStatefulService.cs b/test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatefulService.cs similarity index 90% rename from test/Test.Scenario.InternalsVisible/InternalsVisibleStatefulService.cs rename to test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatefulService.cs index 1e94735..9acf850 100644 --- a/test/Test.Scenario.InternalsVisible/InternalsVisibleStatefulService.cs +++ b/test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatefulService.cs @@ -2,7 +2,7 @@ using Microsoft.ServiceFabric.Data; using Microsoft.ServiceFabric.Services.Runtime; -namespace Test.Scenario.InternalsVisible +namespace Test.Scenario.InternalsVisible.Services { // ReSharper disable once UnusedMember.Global internal class InternalsVisibleStatefulService : StatefulServiceBase diff --git a/test/Test.Scenario.InternalsVisible/InternalsVisibleStatelessService.cs b/test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatelessService.cs similarity index 87% rename from test/Test.Scenario.InternalsVisible/InternalsVisibleStatelessService.cs rename to test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatelessService.cs index 59ac668..e5ceb35 100644 --- a/test/Test.Scenario.InternalsVisible/InternalsVisibleStatelessService.cs +++ b/test/Test.Scenario.InternalsVisible.Services/InternalsVisibleToStatelessService.cs @@ -1,7 +1,7 @@ using System.Fabric; using Microsoft.ServiceFabric.Services.Runtime; -namespace Test.Scenario.InternalsVisible +namespace Test.Scenario.InternalsVisible.Services { // ReSharper disable once UnusedMember.Global internal class InternalsVisibleStatelessService : StatelessService diff --git a/test/Test.Scenario.InternalsVisible.Services/Test.Scenario.InternalsVisible.Services.csproj b/test/Test.Scenario.InternalsVisible.Services/Test.Scenario.InternalsVisible.Services.csproj new file mode 100644 index 0000000..43359e9 --- /dev/null +++ b/test/Test.Scenario.InternalsVisible.Services/Test.Scenario.InternalsVisible.Services.csproj @@ -0,0 +1,18 @@ + + + + netcoreapp3.1 + enable + latest + enable + false + + + + + + + + + + diff --git a/test/Test.Scenario.InternalsVisible/Properties/AssemblyInfo.cs b/test/Test.Scenario.InternalsVisible/Properties/AssemblyInfo.cs deleted file mode 100644 index 99cbe97..0000000 --- a/test/Test.Scenario.InternalsVisible/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -using System.Runtime.CompilerServices; -using Castle.Core.Internal; - -[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Test, PublicKey=00240000048000009400000006020000002400005253413100040000010001008728425885ef385e049261b18878327dfaaf0d666dea3bd2b0e4f18b33929ad4e5fbc9087e7eda3c1291d2de579206d9b4292456abffbe8be6c7060b36da0c33b883e3878eaf7c89fddf29e6e27d24588e81e86f3a22dd7b1a296b5f06fbfb500bbd7410faa7213ef4e2ce7622aefc03169b0324bcd30ccfe9ac8204e4960be6")] -[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] \ No newline at end of file From 026f005dd6ab2ff78996d7176d88fee96f023695 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Wed, 14 Sep 2022 20:20:17 -0500 Subject: [PATCH 3/3] Fixed "Access Denied" exceptions thrown in unit tests by removing strong-name signing. --- src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs | 2 +- .../AssemblyInfo.cs | 5 ++--- test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs | 5 ++--- test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs b/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs index 5b5d1ed..6d89ad8 100644 --- a/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs +++ b/src/Autofac.Integration.ServiceFabric.Actors/AssemblyInfo.cs @@ -7,5 +7,5 @@ [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] [assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Actors.Test")] -[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] +[assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")] // [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] [assembly: SuppressMessage("Microsoft.Design", "CA1020", Scope = "namespace", Target = "Autofac.Integration.ServiceFabric.Actors")] diff --git a/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs b/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs index aa8c6b3..4485e64 100644 --- a/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs +++ b/src/Autofac.Integration.ServiceFabric.Services/AssemblyInfo.cs @@ -2,10 +2,9 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using Castle.Core.Internal; [assembly: ComVisible(false)] [assembly: CLSCompliant(false)] -[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Services.Test")] -[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] [assembly: SuppressMessage("Microsoft.Design", "CA1020", Scope = "namespace", Target = "Autofac.Integration.ServiceFabric.Services")] +[assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Services.Test")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] // Use this if we have a strongly named assembly ourselves [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] diff --git a/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs b/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs index 2d3ae12..a0777d9 100644 --- a/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs +++ b/test/Test.Scenario.InternalsVisible.Actors/AssemblyInfo.cs @@ -1,5 +1,4 @@ -using Castle.Core.Internal; -using System.Runtime.CompilerServices; +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("Autofac.Integration.ServiceFabric.Actors.Test")] -[assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] diff --git a/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs b/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs index e4d4730..2bf3dca 100644 --- a/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs +++ b/test/Test.Scenario.InternalsVisible.Services/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Runtime.CompilerServices; -using Castle.Core.Internal; [assembly:InternalsVisibleTo("Autofac.Integration.ServiceFabric.Services.Test")] -[assembly:InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] +[assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")]