diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets index e7c1bc0c..52f41c60 100644 --- a/.paket/Paket.Restore.targets +++ b/.paket/Paket.Restore.targets @@ -11,23 +11,49 @@ $(MSBuildThisFileDirectory)..\ $(PaketRootPath)paket-files\paket.restore.cached $(PaketRootPath)paket.lock + classic + proj + assembly + native /Library/Frameworks/Mono.framework/Commands/mono mono - - $(PaketRootPath)paket.exe - $(PaketToolsPath)paket.exe - "$(PaketExePath)" - $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" - + + $(PaketRootPath)paket.bootstrapper.exe + $(PaketToolsPath)paket.bootstrapper.exe + $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\ + + + + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + $(PaketToolsPath)paket.exe + $(_PaketBootStrapperExeDir)paket.exe + paket.exe + + + $(PaketRootPath)paket + $(PaketToolsPath)paket + $(PaketToolsPath)paket + + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + + + $(PaketBootStrapperExeDir)paket.exe + + + paket + + <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)")) - dotnet "$(PaketExePath)" + dotnet "$(PaketExePath)" + $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" + "$(PaketExePath)" - - "$(PaketExePath)" - $(PaketRootPath)paket.bootstrapper.exe - $(PaketToolsPath)paket.bootstrapper.exe "$(PaketBootStrapperExePath)" $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)" @@ -36,30 +62,40 @@ true true + + + True - + + + + + true - $(NoWarn);NU1603 + $(NoWarn);NU1603;NU1604;NU1605;NU1608 - /usr/bin/shasum $(PaketRestoreCacheFile) | /usr/bin/awk '{ print $1 }' - /usr/bin/shasum $(PaketLockFilePath) | /usr/bin/awk '{ print $1 }' + /usr/bin/shasum "$(PaketRestoreCacheFile)" | /usr/bin/awk '{ print $1 }' + /usr/bin/shasum "$(PaketLockFilePath)" | /usr/bin/awk '{ print $1 }' - + - + + + + $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)')) @@ -69,11 +105,26 @@ true + + + true + + - + + + + + + + + $(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached @@ -82,7 +133,9 @@ $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references $(MSBuildProjectDirectory)\paket.references - $(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).$(TargetFramework).paket.resolved + + false + true true references-file-or-cache-not-found @@ -101,32 +154,43 @@ - + true - target-framework '$(TargetFramework)' + target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths) - + + - + + false + true + + - + - + + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) %(PaketReferencesFileLinesInfo.PackageVersion) - All + All + runtime + runtime + true + true @@ -158,19 +222,27 @@ false + $(MSBuildVersion) + 15.8.0 <_NuspecFilesNewLocation Include="$(BaseIntermediateOutputPath)$(Configuration)\*.nuspec"/> + + $(MSBuildProjectDirectory)/$(MSBuildProjectFile) true - false - true + false + true + false + true + false + true $(BaseIntermediateOutputPath)$(Configuration) $(BaseIntermediateOutputPath) @@ -183,11 +255,54 @@ - - + - + + - Properties Gigya.Microdot.Configuration Gigya.Microdot.Configuration - v4.5.1 + v4.7.2 512 @@ -20,9 +20,11 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 false bin\Debug\Gigya.Microdot.Configuration.xml + + pdbonly @@ -32,6 +34,9 @@ prompt 4 + + true + @@ -94,7 +99,7 @@ --> - + True @@ -111,7 +116,7 @@ - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -122,7 +127,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -133,7 +138,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -144,10 +149,24 @@ - + + + + True + + + ..\packages\System.ComponentModel.Annotations\lib\net461\System.ComponentModel.Annotations.dll + True + True + + + + + + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True diff --git a/Gigya.Microdot.Fakes/Gigya.Microdot.Fakes.csproj b/Gigya.Microdot.Fakes/Gigya.Microdot.Fakes.csproj index ebd36b1f..850df21c 100644 --- a/Gigya.Microdot.Fakes/Gigya.Microdot.Fakes.csproj +++ b/Gigya.Microdot.Fakes/Gigya.Microdot.Fakes.csproj @@ -9,7 +9,7 @@ Properties Gigya.Microdot.Fakes Gigya.Microdot.Fakes - v4.5.1 + v4.7.2 512 @@ -20,9 +20,10 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Fakes.xml - 1591;1573 + + true @@ -96,7 +97,7 @@ --> - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -107,10 +108,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True diff --git a/Gigya.Microdot.Hosting/Gigya.Microdot.Hosting.csproj b/Gigya.Microdot.Hosting/Gigya.Microdot.Hosting.csproj index e3a15e35..db7a3e0d 100644 --- a/Gigya.Microdot.Hosting/Gigya.Microdot.Hosting.csproj +++ b/Gigya.Microdot.Hosting/Gigya.Microdot.Hosting.csproj @@ -9,7 +9,7 @@ Properties Gigya.Microdot.Hosting Gigya.Microdot.Hosting - v4.5.1 + v4.7.2 512 ..\ @@ -25,7 +25,8 @@ true prompt MinimumRecommendedRules.ruleset - 1591;1573;1587 + 1587 + 3 bin\Release\ @@ -90,7 +91,9 @@ - + + Designer + Designer @@ -126,7 +129,7 @@ --> - + True @@ -152,7 +155,7 @@ - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -163,7 +166,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -174,7 +177,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -185,10 +188,10 @@ - + - ..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -196,10 +199,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -207,10 +210,13 @@ - + + + True + - ..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + ..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll True True diff --git a/Gigya.Microdot.Hosting/HttpService/ServerRequestPublisher.cs b/Gigya.Microdot.Hosting/HttpService/ServerRequestPublisher.cs index 80813667..7e0fc51d 100644 --- a/Gigya.Microdot.Hosting/HttpService/ServerRequestPublisher.cs +++ b/Gigya.Microdot.Hosting/HttpService/ServerRequestPublisher.cs @@ -18,15 +18,15 @@ public interface IServerRequestPublisher public class ServerRequestPublisher : IServerRequestPublisher { private readonly IEventPublisher _eventPublisher; - private readonly IPropertiesMetadataPropertiesCache _metadataPropertiesCache; + private readonly IMembersToLogExtractor _membersToLogExtractor; private readonly IServiceEndPointDefinition _serviceEndPointDefinition; public ServerRequestPublisher(IEventPublisher eventPublisher, - IPropertiesMetadataPropertiesCache metadataPropertiesCache, + IMembersToLogExtractor membersToLogExtractor, IServiceEndPointDefinition serviceEndPointDefinition) { _eventPublisher = eventPublisher; - _metadataPropertiesCache = metadataPropertiesCache; + _membersToLogExtractor = membersToLogExtractor; _serviceEndPointDefinition = serviceEndPointDefinition; } @@ -58,7 +58,7 @@ public void TryPublish(ServiceCallEvent callEvent, IEnumerable var type = pair.Value?.GetType(); if (type?.IsClass==true) { - var metaParams = _metadataPropertiesCache.ParseIntoParams(pair.Value); + var metaParams = _membersToLogExtractor.ExtractMembersToLog(pair.Value); foreach (var metaParam in metaParams) { diff --git a/Gigya.Microdot.Hosting/Validators/SensitivityAttributesValidator.cs b/Gigya.Microdot.Hosting/Validators/SensitivityAttributesValidator.cs index 3282e6ec..f6ecc536 100644 --- a/Gigya.Microdot.Hosting/Validators/SensitivityAttributesValidator.cs +++ b/Gigya.Microdot.Hosting/Validators/SensitivityAttributesValidator.cs @@ -73,7 +73,7 @@ private bool IsIrrelevantTypes(Type type) return false; } - private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string methodName, string paramName, Type type, Stack path) + private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string methodName, string paramName, Type type, Stack path, bool isGenericPayload = false) { if (type.IsClass == false || IsIrrelevantTypes(type)) return; @@ -81,6 +81,10 @@ private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string metho if (path.Count == 100) throw new StackOverflowException($"In Method {methodName} {paramName} cuased for 'StackOverflowException' - Probably due to circular references."); + Type[] typeArguments = null; + if (type.IsGenericType) + typeArguments = type.GetGenericArguments(); + foreach (var memberInfo in type.FindMembers(MemberTypes.Property | MemberTypes.Field, BindingFlags.Public | BindingFlags.Instance, null, null) .Where(x => x is FieldInfo || (x is PropertyInfo propertyInfo) && propertyInfo.CanRead)) { @@ -89,14 +93,23 @@ private void VerifyMisplacedSensitiveAttribute(bool logFieldExists, string metho if (memberInfo.GetCustomAttribute(typeof(SensitiveAttribute)) != null || memberInfo.GetCustomAttribute(typeof(NonSensitiveAttribute)) != null) if (!logFieldExists) throw new ProgrammaticException($"The method '{methodName}' parameter '{paramName}' has a member '{string.Join(" --> ", path.Reverse())}' that is marked as [Sensitive] or [NonSensitive], but the method parameter is not marked with [LogFields]"); - else if (path.Count > 1) + else if (IsInvalidAttributeLevelPlacement(isGenericPayload, path.Count)) throw new ProgrammaticException($"The method '{methodName}' parameter '{paramName}' has a member '{string.Join(" --> ", path.Reverse())}' that is marked as [Sensitive] or [NonSensitive], but only root-level members can be marked as such."); Type memberType = memberInfo is PropertyInfo propertyInfo ? propertyInfo.PropertyType : ((FieldInfo)memberInfo).FieldType; - VerifyMisplacedSensitiveAttribute(logFieldExists, methodName, paramName, memberType, path); + var isGeneric = typeArguments != null && typeArguments.Contains(memberType); + VerifyMisplacedSensitiveAttribute(logFieldExists, methodName, paramName, memberType, path, isGeneric); path.Pop(); } } + + private bool IsInvalidAttributeLevelPlacement(bool isGenericPayload, int pathCount) + { + if (isGenericPayload) + return pathCount > 2; //Allow only attributes on one level of generic payload + else + return pathCount > 1; //Allow only attributes on root level + } } } \ No newline at end of file diff --git a/Gigya.Microdot.Hosting/app.config b/Gigya.Microdot.Hosting/app.config index b588bc72..4e15c3f7 100644 --- a/Gigya.Microdot.Hosting/app.config +++ b/Gigya.Microdot.Hosting/app.config @@ -1,3 +1,3 @@ - + - + diff --git a/Gigya.Microdot.Interfaces/Gigya.Microdot.Interfaces.csproj b/Gigya.Microdot.Interfaces/Gigya.Microdot.Interfaces.csproj index 10f2ac3b..972514fc 100644 --- a/Gigya.Microdot.Interfaces/Gigya.Microdot.Interfaces.csproj +++ b/Gigya.Microdot.Interfaces/Gigya.Microdot.Interfaces.csproj @@ -9,7 +9,7 @@ Properties Gigya.Microdot.Interfaces Gigya.Microdot.Interfaces - v4.5.1 + v4.7.2 512 @@ -20,8 +20,9 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Interfaces.xml + 1591 pdbonly @@ -82,7 +83,7 @@ --> - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll diff --git a/Gigya.Microdot.Logging.NLog/Gigya.Microdot.Logging.NLog.csproj b/Gigya.Microdot.Logging.NLog/Gigya.Microdot.Logging.NLog.csproj index b8488849..7e71bd72 100644 --- a/Gigya.Microdot.Logging.NLog/Gigya.Microdot.Logging.NLog.csproj +++ b/Gigya.Microdot.Logging.NLog/Gigya.Microdot.Logging.NLog.csproj @@ -9,8 +9,9 @@ Properties Gigya.Microdot.Logging.NLog Gigya.Microdot.Logging.NLog - v4.5.1 + v4.7.2 512 + true @@ -19,7 +20,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Logging.NLog.xml @@ -66,7 +67,7 @@ - + ..\packages\Ninject\lib\net45\Ninject.dll @@ -77,7 +78,7 @@ - + True diff --git a/Gigya.Microdot.Ninject.Host/App.config b/Gigya.Microdot.Ninject.Host/App.config index 33677514..2906cd41 100644 --- a/Gigya.Microdot.Ninject.Host/App.config +++ b/Gigya.Microdot.Ninject.Host/App.config @@ -1,12 +1,12 @@ - + - + True - - + + - \ No newline at end of file + diff --git a/Gigya.Microdot.Ninject.Host/Gigya.Microdot.Ninject.Host.csproj b/Gigya.Microdot.Ninject.Host/Gigya.Microdot.Ninject.Host.csproj index 22b6dccf..96b9267d 100644 --- a/Gigya.Microdot.Ninject.Host/Gigya.Microdot.Ninject.Host.csproj +++ b/Gigya.Microdot.Ninject.Host/Gigya.Microdot.Ninject.Host.csproj @@ -8,9 +8,10 @@ Library Gigya.Microdot.Ninject.Host Gigya.Microdot.Ninject.Host - v4.5.1 + v4.7.2 512 true + AnyCPU @@ -20,7 +21,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Ninject.Host.xml @@ -52,7 +53,9 @@ - + + Designer + @@ -80,7 +83,7 @@ - + True @@ -94,7 +97,7 @@ - + ..\packages\Ninject\lib\net45\Ninject.dll @@ -105,7 +108,7 @@ - + ..\packages\Ninject.Extensions.Conventions\lib\net45\Ninject.Extensions.Conventions.dll @@ -116,7 +119,7 @@ - + ..\packages\Ninject.Extensions.Factory\lib\net45\Ninject.Extensions.Factory.dll @@ -127,10 +130,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True diff --git a/Gigya.Microdot.Ninject/Gigya.Microdot.Ninject.csproj b/Gigya.Microdot.Ninject/Gigya.Microdot.Ninject.csproj index 5a98aa41..d98c4e87 100644 --- a/Gigya.Microdot.Ninject/Gigya.Microdot.Ninject.csproj +++ b/Gigya.Microdot.Ninject/Gigya.Microdot.Ninject.csproj @@ -9,8 +9,9 @@ Properties Gigya.Microdot.Ninject Gigya.Microdot.Ninject - v4.5.1 + v4.7.2 512 + true @@ -19,7 +20,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Ninject.xml @@ -87,7 +88,7 @@ - + True @@ -101,7 +102,7 @@ - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -112,7 +113,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -123,7 +124,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -134,7 +135,7 @@ - + ..\packages\Ninject\lib\net45\Ninject.dll @@ -145,7 +146,7 @@ - + ..\packages\Ninject.Extensions.Conventions\lib\net45\Ninject.Extensions.Conventions.dll @@ -156,7 +157,7 @@ - + ..\packages\Ninject.Extensions.Factory\lib\net45\Ninject.Extensions.Factory.dll @@ -167,10 +168,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True diff --git a/Gigya.Microdot.Ninject/MicrodotModule.cs b/Gigya.Microdot.Ninject/MicrodotModule.cs index 0bdd7352..794d355d 100644 --- a/Gigya.Microdot.Ninject/MicrodotModule.cs +++ b/Gigya.Microdot.Ninject/MicrodotModule.cs @@ -93,6 +93,7 @@ public override void Load() Bind().To().InTransientScope(); Rebind().To().InTransientScope(); + Rebind().ToSelf().InTransientScope(); Bind().To().InSingletonScope(); Rebind() diff --git a/Gigya.Microdot.Orleans.Hosting/Gigya.Microdot.Orleans.Hosting.csproj b/Gigya.Microdot.Orleans.Hosting/Gigya.Microdot.Orleans.Hosting.csproj index 69258aad..378b8c61 100644 --- a/Gigya.Microdot.Orleans.Hosting/Gigya.Microdot.Orleans.Hosting.csproj +++ b/Gigya.Microdot.Orleans.Hosting/Gigya.Microdot.Orleans.Hosting.csproj @@ -1,5 +1,6 @@  + Debug @@ -9,7 +10,7 @@ Properties Gigya.Microdot.Orleans.Hosting Gigya.Microdot.Orleans.Hosting - v4.5.1 + v4.7.2 512 @@ -20,7 +21,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Orleans.Hosting.xml @@ -69,6 +70,13 @@ + + + + <__paket__NETStandard_Library_targets>netstandard2.0\NETStandard.Library + + + - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -141,7 +142,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -152,7 +153,7 @@ - + True @@ -176,7 +177,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -187,7 +188,7 @@ - + ..\packages\Nito.AsyncEx\lib\net45\Nito.AsyncEx.dll @@ -208,10 +209,10 @@ - + - ..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -219,10 +220,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -230,10 +231,13 @@ - + + + True + - ..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + ..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll True True diff --git a/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram.png b/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram.png index f50969ae..7f305dc4 100644 Binary files a/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram.png and b/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram.png differ diff --git a/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram_from_draw.io.xml b/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram_from_draw.io.xml index 8de5324b..291c19ed 100644 --- a/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram_from_draw.io.xml +++ b/Gigya.Microdot.ServiceDiscovery/Rewrite/_diagram_from_draw.io.xml @@ -1 +1 @@ -7V1bc6O4Ev41rso+HBdCXB9jz8zOVGVO7Ul2a58VW7GpwcgHcBLvr19xEUYStxBheyZypVJGFhLQX3/d6pbEDC53r7/HaL/9TtY4nJnG+nUGP81M0/cg/Z8VHIsCmxVs4mBdFIFTwUPwDy4LjbL0EKxxwlVMCQnTYM8XrkgU4VXKlaE4Ji98tScS8r3u0QZLBQ8rFMqlfwfrdFuUeqZ7Kv+Kg82W9Qwcv/jlEa1+bGJyiMr+ZiZ8yj/FzzvE2ipvNNmiNXmpFcHPM7iMCUmLb7vXJQ6zR8seW3Hel5Zfq+uOcZQOOcGxizOeUXjA7JLzC0uP7GHgaH2bPVN69BiS1Y8ZXKxRssVZE4Ae0N+/BLRV+Mkojkp5Ano3i226C8t6SRqTH3hJQhLnDUMj/1S/sCed1X0iUcqascrj2pl+/sl6W1O5lZdK4nRLNiRC4edT6SIXRn6tWU/FzWVncQ8sIYd4VRY5lvwQGQZRvMFlkQ0rcVEtwGSH0/hI67yc8AKcUsoxDlEaPPN9ohKjm+rcqrk/SEB7No1SnWyGrlKbfNfimyguvzyrLm2hIc8VGjI9vqHi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w0eObwGB3poEgRaqcfxTCGCd8Na2ewPj6JzWUOHk0xp60u5fpwcijC69mpdyfx6UEywthGx/r00JYye2KMW9YLY3wSBlyX19Gx3+6q3HZ8shUjF+zdk7YAtj7824HqRYqAdRa4AqErvgpX6YrD+nrTspJVW78vGl3V39Wqct5LioSdta9ZBaKxAkdYYz068TxN5iRaBq5RwLXV1nEzeF6m0RP/8vTsPFOlFArrix4tNnBeED2UphQ6HuWq3QNWs0veEcjHOrDNDftIlOvAKLNgPmBfe9eafPIxVEoH1rc63lqgZpF4W9fGIhvSqId1SRXFskjYSSgG/fvjKQb/XBVsqDOKwRE3bceR/mxSw1+ohxQ+rLrFdwD2zMjrSgdQ74JrtAiPpKRyq4d2sgiCLbKtYU7vwQl4QOv19KeUbBDvNj4UPqCXccTOetxXj73N+ke0IKzG/wE= \ No newline at end of file diff --git a/Gigya.Microdot.ServiceProxy/Gigya.Microdot.ServiceProxy.csproj b/Gigya.Microdot.ServiceProxy/Gigya.Microdot.ServiceProxy.csproj index 3d6106f7..aeecd6a1 100644 --- a/Gigya.Microdot.ServiceProxy/Gigya.Microdot.ServiceProxy.csproj +++ b/Gigya.Microdot.ServiceProxy/Gigya.Microdot.ServiceProxy.csproj @@ -9,8 +9,9 @@ Properties Gigya.Microdot.ServiceProxy Gigya.Microdot.ServiceProxy - v4.5.1 + v4.7.2 512 + true @@ -19,7 +20,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.ServiceProxy.xml 1591;1573 true @@ -105,7 +106,7 @@ --> - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -116,7 +117,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -127,7 +128,7 @@ - + True @@ -151,7 +152,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -162,7 +163,7 @@ - + ..\packages\Nito.AsyncEx\lib\net45\Nito.AsyncEx.dll @@ -183,10 +184,10 @@ - + - ..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -194,10 +195,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -205,10 +206,13 @@ - + + + True + - ..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + ..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll True True diff --git a/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs b/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs index 2c98c816..2cef0322 100644 --- a/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs +++ b/Gigya.Microdot.ServiceProxy/ServiceProxyProvider.cs @@ -104,7 +104,7 @@ public class ServiceProxyProvider : IDisposable, IServiceProxyProvider private readonly Counter _hostFailureCounter; private readonly Counter _applicationExceptionCounter; - private HttpMessageHandler _httpMessageHandler = new WebRequestHandler(); + private HttpMessageHandler _httpMessageHandler = new HttpClientHandler(); protected internal HttpMessageHandler HttpMessageHandler { @@ -210,9 +210,9 @@ private HttpClient GetHttpClient(ServiceDiscoveryConfig config) private void InitHttps(string securityRole) { if (HttpMessageHandler == null) - HttpMessageHandler = new WebRequestHandler(); + HttpMessageHandler = new HttpClientHandler(); - var wrh = HttpMessageHandler as WebRequestHandler; + var wrh = HttpMessageHandler as HttpClientHandler; if (wrh == null) throw new ProgrammaticException("When using HTTPS in ServiceProxy, only WebRequestHandler is supported.", unencrypted: new Tags { { "HandlerType", HttpMessageHandler.GetType().FullName } }); @@ -222,7 +222,7 @@ private void InitHttps(string securityRole) wrh.ClientCertificates.Add(clientCert); - wrh.ServerCertificateValidationCallback = (sender, serverCertificate, serverChain, errors) => + wrh.ServerCertificateCustomValidationCallback = (sender, serverCertificate, serverChain, errors) => { switch (errors) { diff --git a/Gigya.Microdot.SharedLogic/Events/MembersToLogExtractor.cs b/Gigya.Microdot.SharedLogic/Events/MembersToLogExtractor.cs new file mode 100644 index 00000000..a692f050 --- /dev/null +++ b/Gigya.Microdot.SharedLogic/Events/MembersToLogExtractor.cs @@ -0,0 +1,181 @@ +#region Copyright +// Copyright 2017 Gigya Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +#endregion + + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Reflection; +using Gigya.Microdot.Interfaces.Logging; +using Gigya.ServiceContract.Attributes; + +namespace Gigya.Microdot.SharedLogic.Events +{ + public class ReflectionMetadataInfo + { + public string Name { get; set; } + public Func ValueExtractor { get; set; } + public Sensitivity? Sensitivity { get; set; } + public ReflectionMetadataInfo[] InnerMembers { get; set; } + } + + public interface IMembersToLogExtractor + { + IEnumerable ExtractMembersToLog(object instance); + } + + public class MetadataCacheParam + { + public string Name { get; set; } + public object Value { get; set; } + public Sensitivity? Sensitivity { get; set; } + + } + + public class MembersToLogExtractor : IMembersToLogExtractor + { + private readonly ILog _log; + private readonly ConcurrentDictionary _membersMetadataCache; + + public MembersToLogExtractor(ILog log) + { + _log = log; + _membersMetadataCache = new ConcurrentDictionary(); + } + + public IEnumerable ExtractMembersToLog(object instance) + { + var type = instance.GetType(); + var propertiesMetadata = _membersMetadataCache.GetOrAdd(type, x => ExtractMemberMetadata(type).ToArray()); + + return ExtractMembers(instance, propertiesMetadata); + } + + private IEnumerable ExtractMembers(object instance, IEnumerable membersMetadata, string containingName = null) + { + foreach (var memberMetadata in membersMetadata) + { + object value; + + try + { + value = memberMetadata.ValueExtractor(instance); + } + catch (Exception ex) + { + _log.Warn("This member is invalid", unencryptedTags: new { propertyName = memberMetadata.Name }, exception: ex); + continue; + } + + var memberName = containingName == null ? memberMetadata.Name : $"{containingName}_{memberMetadata.Name}"; + + if (memberMetadata.InnerMembers != null && memberMetadata.InnerMembers.Length > 0) + foreach (var metadataCacheParam in ExtractMembers(value, memberMetadata.InnerMembers, memberName)) yield return metadataCacheParam; + else //In case the if flow was executed, we don't want to return the current item + //because it's a generic payload (class) and not a member + { + yield return new MetadataCacheParam + { + Name = memberName, + Value = value, + Sensitivity = memberMetadata.Sensitivity + }; + } + } + } + + private const int MaxRecursionDepth = 1; + + internal IEnumerable ExtractMemberMetadata(Type type, int recursionDepth = 0, + Sensitivity? parentSensitivity = null) + { + var members = type.FindMembers(MemberTypes.Property | MemberTypes.Field, + BindingFlags.Public | BindingFlags.Instance, null, null) + .Where(x => x is FieldInfo || ((x is PropertyInfo propertyInfo) && propertyInfo.CanRead)); + + var typeArguments = recursionDepth < MaxRecursionDepth && type.IsGenericType + ? type.GetGenericArguments() + : null; + + foreach (var member in members) + { + var instanceParameter = Expression.Parameter(typeof(object), "target"); + MemberExpression memberExpression = null; + + if (member.MemberType == MemberTypes.Property) + memberExpression = Expression.Property(Expression.Convert(instanceParameter, member.DeclaringType), + (PropertyInfo) member); + else if (member.MemberType == MemberTypes.Field) + memberExpression = Expression.Field(Expression.Convert(instanceParameter, member.DeclaringType), + (FieldInfo) member); + + var converter = Expression.Convert(memberExpression, typeof(object)); + var lambda = Expression.Lambda>(converter, instanceParameter); + + var memberSensitivity = ExtractSensitivity(member) ?? parentSensitivity; + + var memberType = GetMemberUnderlyingType(member); + var hasInnerMembers = typeArguments != null && typeArguments.Contains(memberType); + + yield return new ReflectionMetadataInfo + { + Name = member.Name, + ValueExtractor = lambda.Compile(), + Sensitivity = memberSensitivity, + InnerMembers = hasInnerMembers + ? ExtractMemberMetadata(memberType, recursionDepth + 1, memberSensitivity).ToArray() + : null + }; + } + } + + private Type GetMemberUnderlyingType(MemberInfo member) + { + switch (member.MemberType) + { + case MemberTypes.Field: + return ((FieldInfo)member).FieldType; + case MemberTypes.Property: + return ((PropertyInfo)member).PropertyType; + default: + throw new ArgumentException("MemberInfo must be of type FieldInfo or PropertyInfo", "member"); + } + } + + + internal Sensitivity? ExtractSensitivity(MemberInfo memberInfo) + { + if (memberInfo.GetCustomAttribute()?.Secretive == true) + return Sensitivity.Secretive; + + else if (memberInfo.GetCustomAttribute()?.Secretive == false) + return Sensitivity.Sensitive; + + else if (memberInfo.GetCustomAttribute() != null) + return Sensitivity.NonSensitive; + + else return null; + } + } +} diff --git a/Gigya.Microdot.SharedLogic/Events/MetadataPropertiesCache.cs b/Gigya.Microdot.SharedLogic/Events/MetadataPropertiesCache.cs deleted file mode 100644 index defeb354..00000000 --- a/Gigya.Microdot.SharedLogic/Events/MetadataPropertiesCache.cs +++ /dev/null @@ -1,157 +0,0 @@ -#region Copyright -// Copyright 2017 Gigya Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -#endregion - - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Linq.Expressions; -using System.Reflection; -using Gigya.Microdot.Interfaces.Logging; -using Gigya.ServiceContract.Attributes; - -namespace Gigya.Microdot.SharedLogic.Events -{ - - public class ReflectionMetadataInfo - { - public string Name { get; set; } - public Func ValueExtractor { get; set; } - public Sensitivity? Sensitivity { get; set; } - } - - public interface IPropertiesMetadataPropertiesCache - { - IEnumerable ParseIntoParams(object instance); - } - - public class MetadataCacheParam - { - public string Name { get; set; } - public object Value { get; set; } - public Sensitivity? Sensitivity { get; set; } - - } - - - public class PropertiesMetadataPropertiesCache : IPropertiesMetadataPropertiesCache - { - private readonly ILog _log; - private readonly ConcurrentDictionary _propertyMetadataCache; - - public PropertiesMetadataPropertiesCache(ILog log) - { - _log = log; - _propertyMetadataCache = new ConcurrentDictionary(); - - } - - public IEnumerable ParseIntoParams(object instance) - { - var type = instance.GetType(); - var result = ExtracParams(instance, type); - - return result; - } - - private IEnumerable ExtracParams(object instance, Type type) - { - var propertyMetadata = _propertyMetadataCache.GetOrAdd(type, x => ExtracMemberMetadata(instance, type).ToArray()); - - foreach (var item in propertyMetadata) - { - object value; - - try - { - value = item.ValueExtractor(instance); - } - catch (Exception ex) - { - _log.Warn("This property is invalid", unencryptedTags: new { propertyName = item.Name }, exception: ex); - continue; - } - - yield return new MetadataCacheParam - { - Name = item.Name, - Value = value, - Sensitivity = item.Sensitivity - }; - } - } - - internal static IEnumerable ExtracMemberMetadata(object instance, Type type) - { - var list = new List(); - var members = type.FindMembers(MemberTypes.Property | MemberTypes.Field, - BindingFlags.Public | BindingFlags.Instance, null, null) - .Where(x => x is FieldInfo || ((x is PropertyInfo propertyInfo) && propertyInfo.CanRead)); - - foreach (var member in members) - { - var instanceParameter = Expression.Parameter(typeof(object), "target"); - MemberExpression memberExpression = null; - - if (member.MemberType == MemberTypes.Property) - memberExpression = Expression.Property(Expression.Convert(instanceParameter, member.DeclaringType), (PropertyInfo)member); - else if (member.MemberType == MemberTypes.Field) - memberExpression = Expression.Field(Expression.Convert(instanceParameter, member.DeclaringType), (FieldInfo)member); - - var converter = Expression.Convert(memberExpression, typeof(object)); - var lambda = Expression.Lambda>(converter, instanceParameter); - - list.Add(new ReflectionMetadataInfo - { - Name = member.Name, - ValueExtractor = lambda.Compile(), - Sensitivity = ExtractSensitivity(member) - }); - } - return list; - } - - internal static Sensitivity? ExtractSensitivity(MemberInfo memberInfo) - { - var attribute = memberInfo.GetCustomAttributes() - .FirstOrDefault(x => x is SensitiveAttribute || x is NonSensitiveAttribute); - - if (attribute != null) - { - if (attribute is SensitiveAttribute sensitiveAttibute) - { - if (sensitiveAttibute.Secretive) - { - return Sensitivity.Secretive; - } - - return Sensitivity.Sensitive; - - } - return Sensitivity.NonSensitive; - } - - return null; - } - } -} diff --git a/Gigya.Microdot.SharedLogic/Gigya.Microdot.SharedLogic.csproj b/Gigya.Microdot.SharedLogic/Gigya.Microdot.SharedLogic.csproj index 882555a8..c706d9ba 100644 --- a/Gigya.Microdot.SharedLogic/Gigya.Microdot.SharedLogic.csproj +++ b/Gigya.Microdot.SharedLogic/Gigya.Microdot.SharedLogic.csproj @@ -9,8 +9,9 @@ Properties Gigya.Microdot.SharedLogic Gigya.Microdot.SharedLogic - v4.5.1 + v4.7.2 512 + true @@ -19,7 +20,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.SharedLogic.xml 1591;1573 true @@ -47,7 +48,7 @@ - + @@ -125,7 +126,7 @@ --> - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -136,7 +137,7 @@ - + ..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -147,7 +148,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -158,10 +159,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -169,10 +170,13 @@ - + + + True + - ..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + ..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll True True diff --git a/Gigya.Microdot.Testing.Shared/App.config b/Gigya.Microdot.Testing.Shared/App.config index 24d5172e..1e59c434 100644 --- a/Gigya.Microdot.Testing.Shared/App.config +++ b/Gigya.Microdot.Testing.Shared/App.config @@ -34,11 +34,6 @@ - - True - - - True diff --git a/Gigya.Microdot.Testing.Shared/Gigya.Microdot.Testing.Shared.csproj b/Gigya.Microdot.Testing.Shared/Gigya.Microdot.Testing.Shared.csproj index 5a97f39e..d4581759 100644 --- a/Gigya.Microdot.Testing.Shared/Gigya.Microdot.Testing.Shared.csproj +++ b/Gigya.Microdot.Testing.Shared/Gigya.Microdot.Testing.Shared.csproj @@ -8,9 +8,10 @@ Library Gigya.Microdot.Testing.Shared Gigya.Microdot.Testing.Shared - v4.5.1 + v4.7.2 512 true + AnyCPU @@ -20,7 +21,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Testing.Shared.xml @@ -104,7 +105,7 @@ - + True @@ -118,7 +119,7 @@ - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -129,7 +130,7 @@ - + ..\packages\Microsoft.Orleans.Core\lib\net451\Orleans.dll @@ -140,7 +141,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -151,7 +152,7 @@ - + ..\packages\Ninject\lib\net45\Ninject.dll @@ -162,10 +163,10 @@ - + - ..\packages\NSubstitute\lib\net45\NSubstitute.dll + ..\packages\NSubstitute\lib\net46\NSubstitute.dll True True @@ -173,10 +174,10 @@ - + - ..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -184,10 +185,10 @@ - + - ..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll True True @@ -195,10 +196,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -206,10 +207,10 @@ - + - ..\packages\System.Threading.Tasks.Extensions\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll True True @@ -217,10 +218,13 @@ - + + + True + - ..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + ..\packages\System.ValueTuple\lib\net47\System.ValueTuple.dll True True diff --git a/Gigya.Microdot.Testing/Gigya.Microdot.Testing.csproj b/Gigya.Microdot.Testing/Gigya.Microdot.Testing.csproj index b076cb15..e7d598cc 100644 --- a/Gigya.Microdot.Testing/Gigya.Microdot.Testing.csproj +++ b/Gigya.Microdot.Testing/Gigya.Microdot.Testing.csproj @@ -8,9 +8,10 @@ Library Gigya.Microdot.Testing Gigya.Microdot.Testing - v4.5.1 + v4.7.2 512 true + AnyCPU @@ -20,7 +21,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 bin\Debug\Gigya.Microdot.Testing.xml @@ -106,7 +107,7 @@ - + True @@ -120,7 +121,7 @@ - + ..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -131,7 +132,7 @@ - + ..\packages\Microsoft.Orleans.Core\lib\net451\Orleans.dll @@ -142,7 +143,7 @@ - + ..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -153,7 +154,7 @@ - + ..\packages\Ninject\lib\net45\Ninject.dll @@ -164,10 +165,10 @@ - + - ..\packages\NSubstitute\lib\net45\NSubstitute.dll + ..\packages\NSubstitute\lib\net46\NSubstitute.dll True True @@ -175,10 +176,10 @@ - + - ..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -186,10 +187,10 @@ - + - ..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll True True @@ -197,10 +198,10 @@ - + - ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + ..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -208,10 +209,10 @@ - + - ..\packages\System.Threading.Tasks.Extensions\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll + ..\packages\System.Threading.Tasks.Extensions\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll True True diff --git a/Sample/CalculatorService.Client/App.config b/Sample/CalculatorService.Client/App.config index 8757362b..135cff08 100644 --- a/Sample/CalculatorService.Client/App.config +++ b/Sample/CalculatorService.Client/App.config @@ -1,23 +1,23 @@ - + -
+
- + - + - + True - - + + diff --git a/Sample/CalculatorService.Client/CalculatorService.Client.csproj b/Sample/CalculatorService.Client/CalculatorService.Client.csproj index a2f63c00..5d52506b 100644 --- a/Sample/CalculatorService.Client/CalculatorService.Client.csproj +++ b/Sample/CalculatorService.Client/CalculatorService.Client.csproj @@ -8,7 +8,7 @@ Exe CalculatorService.Client CalculatorService.Client - v4.5.1 + v4.7.2 512 true @@ -21,7 +21,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 false @@ -38,7 +38,9 @@ - + + Designer + PreserveNewest @@ -83,7 +85,7 @@ - + True @@ -97,7 +99,7 @@ - + ..\..\packages\Ninject\lib\net45\Ninject.dll @@ -108,7 +110,7 @@ - + ..\..\packages\Ninject.Extensions.Factory\lib\net45\Ninject.Extensions.Factory.dll diff --git a/Sample/CalculatorService.Interface/CalculatorService.Interface.csproj b/Sample/CalculatorService.Interface/CalculatorService.Interface.csproj index 44c918cf..3ceb3a0a 100644 --- a/Sample/CalculatorService.Interface/CalculatorService.Interface.csproj +++ b/Sample/CalculatorService.Interface/CalculatorService.Interface.csproj @@ -9,7 +9,7 @@ Properties CalculatorService.Interface CalculatorService.Interface - v4.5.1 + v4.7.2 512 @@ -20,7 +20,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 pdbonly @@ -41,7 +41,7 @@ - + ..\..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -52,7 +52,7 @@ - + ..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll diff --git a/Sample/CalculatorService.Orleans/App.config b/Sample/CalculatorService.Orleans/App.config index a0337589..af5d680a 100644 --- a/Sample/CalculatorService.Orleans/App.config +++ b/Sample/CalculatorService.Orleans/App.config @@ -4,7 +4,7 @@
- + diff --git a/Sample/CalculatorService.Orleans/CalculatorService.Orleans.csproj b/Sample/CalculatorService.Orleans/CalculatorService.Orleans.csproj index 865d52d6..5ef238f0 100644 --- a/Sample/CalculatorService.Orleans/CalculatorService.Orleans.csproj +++ b/Sample/CalculatorService.Orleans/CalculatorService.Orleans.csproj @@ -1,5 +1,6 @@  + Debug @@ -8,7 +9,7 @@ Exe CalculatorService.Orleans CalculatorService.Orleans - v4.5.1 + v4.7.2 512 true @@ -21,7 +22,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 false @@ -42,7 +43,9 @@ - + + Designer + PreserveNewest @@ -84,7 +87,7 @@ - + ..\..\packages\Microsoft.CodeAnalysis.Common\lib\net45\Microsoft.CodeAnalysis.dll @@ -95,7 +98,7 @@ - + ..\..\packages\Microsoft.CodeAnalysis.CSharp\lib\net45\Microsoft.CodeAnalysis.CSharp.dll @@ -106,7 +109,7 @@ - + ..\..\packages\Microsoft.Orleans.Core\lib\net451\Orleans.dll @@ -117,7 +120,7 @@ - + ..\..\packages\Microsoft.Orleans.OrleansCodeGenerator\lib\net451\OrleansCodeGenerator.dll @@ -128,7 +131,7 @@ - + ..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -139,7 +142,7 @@ - + ..\..\packages\Ninject\lib\net45\Ninject.dll @@ -150,10 +153,77 @@ - + + + + True + + + ..\..\packages\System.AppContext\lib\net463\System.AppContext.dll + True + True + + + + + + + + + True + + + + + + - ..\..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll + True + True + + + + + + + + + ..\..\packages\System.Console\lib\net46\System.Console.dll + True + True + + + + + + + + + ..\..\packages\System.Diagnostics.FileVersionInfo\lib\net46\System.Diagnostics.FileVersionInfo.dll + True + True + + + + + + + + + ..\..\packages\System.Diagnostics.StackTrace\lib\net46\System.Diagnostics.StackTrace.dll + True + True + + + + + + + + + ..\..\packages\System.IO\lib\net462\System.IO.dll True True @@ -161,10 +231,243 @@ - + + + + ..\..\packages\System.IO.FileSystem\lib\net46\System.IO.FileSystem.dll + True + True + + + + + + + + + ..\..\packages\System.IO.FileSystem.Primitives\lib\net46\System.IO.FileSystem.Primitives.dll + True + True + + + + + + + + + ..\..\packages\System.Linq\lib\net463\System.Linq.dll + True + True + + + + + + + + + ..\..\packages\System.Linq.Expressions\lib\net463\System.Linq.Expressions.dll + True + True + + + + + + + + + ..\..\packages\System.Reflection\lib\net462\System.Reflection.dll + True + True + + + + + + - ..\..\packages\System.Reflection.Metadata\lib\netstandard1.1\System.Reflection.Metadata.dll + ..\..\packages\System.Reflection.Metadata\lib\netstandard2.0\System.Reflection.Metadata.dll + True + True + + + + + + + + + True + + + ..\..\packages\System.Runtime\lib\net462\System.Runtime.dll + True + True + + + + + + + + + ..\..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll + True + True + + + + + + + + + ..\..\packages\System.Runtime.Extensions\lib\net462\System.Runtime.Extensions.dll + True + True + + + + + + + + + ..\..\packages\System.Runtime.InteropServices\lib\net463\System.Runtime.InteropServices.dll + True + True + + + + + + + + + True + + + + + + + + + ..\..\packages\System.Security.Cryptography.Algorithms\lib\net463\System.Security.Cryptography.Algorithms.dll + True + True + + + + + + + + + ..\..\packages\System.Security.Cryptography.Encoding\lib\net46\System.Security.Cryptography.Encoding.dll + True + True + + + + + + + + + ..\..\packages\System.Security.Cryptography.Primitives\lib\net46\System.Security.Cryptography.Primitives.dll + True + True + + + + + + + + + ..\..\packages\System.Security.Cryptography.X509Certificates\lib\net461\System.Security.Cryptography.X509Certificates.dll + True + True + + + + + + + + + ..\..\packages\System.Text.Encoding.CodePages\lib\net461\System.Text.Encoding.CodePages.dll + True + True + + + + + + + + + ..\..\packages\System.Threading.Thread\lib\net46\System.Threading.Thread.dll + True + True + + + + + + + + + True + + + ..\..\packages\System.Xml.ReaderWriter\lib\net46\System.Xml.ReaderWriter.dll + True + True + + + + + + + + + True + + + + + + + + + ..\..\packages\System.Xml.XmlDocument\lib\net46\System.Xml.XmlDocument.dll + True + True + + + + + + + + + ..\..\packages\System.Xml.XPath\lib\net46\System.Xml.XPath.dll + True + True + + + + + + + + + ..\..\packages\System.Xml.XPath.XDocument\lib\net46\System.Xml.XPath.XDocument.dll True True diff --git a/Sample/CalculatorService/App.config b/Sample/CalculatorService/App.config index 2e28582d..43e313c7 100644 --- a/Sample/CalculatorService/App.config +++ b/Sample/CalculatorService/App.config @@ -1,23 +1,23 @@ - + -
+
- + - + - + True - - + + diff --git a/Sample/CalculatorService/CalculatorService.csproj b/Sample/CalculatorService/CalculatorService.csproj index 94573a48..0aaa39c9 100644 --- a/Sample/CalculatorService/CalculatorService.csproj +++ b/Sample/CalculatorService/CalculatorService.csproj @@ -8,7 +8,7 @@ Exe CalculatorService CalculatorService - v4.5.1 + v4.7.2 512 true @@ -36,7 +36,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 false @@ -61,7 +61,9 @@ - + + Designer + PreserveNewest @@ -118,7 +120,7 @@ - + ..\..\packages\Ninject\lib\net45\Ninject.dll diff --git a/SolutionVersion.cs b/SolutionVersion.cs index b199cc20..5f312630 100644 --- a/SolutionVersion.cs +++ b/SolutionVersion.cs @@ -28,9 +28,9 @@ [assembly: AssemblyCopyright("© 2018 Gigya Inc.")] [assembly: AssemblyDescription("Microdot Framework")] -[assembly: AssemblyVersion("1.13.2.0")] -[assembly: AssemblyFileVersion("1.13.2.0")] -[assembly: AssemblyInformationalVersion("1.13.2.0")] +[assembly: AssemblyVersion("1.14.1.0")] +[assembly: AssemblyFileVersion("1.14.1.0")] +[assembly: AssemblyInformationalVersion("1.14.1.0")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from diff --git a/paket.dependencies b/paket.dependencies index be27d5a9..586514dc 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -1,6 +1,6 @@ source https://api.nuget.org/v3/index.json -framework: net451 +framework: net472 redirects: on content: once copy_content_to_output_dir: always @@ -15,9 +15,8 @@ nuget Metrics.NET ~> 0.0 nuget Newtonsoft.Json >= 9 lowest_matching: true nuget Nito.AsyncEx ~> 4.0 nuget System.Threading.Tasks.Dataflow ~> 4.0 -nuget ZooKeeperNetEx ~> 3.4 >= 3.4.7.1 +nuget ZooKeeperNetEx 3.4.12.0 # We have an issue with 3.4.12.1 nuget System.ComponentModel.Annotations ~> 4.0 -nuget System.Collections.Immutable ~> 1.0 nuget DataAnnotationsValidator ~> 2.1.0 # Orleans @@ -43,9 +42,22 @@ nuget Castle.Core ~> 4.0 #Tests only dependencies nuget NUnit ~> 3.0 nuget RichardSzalay.MockHttp -nuget NSubstitute +nuget NSubstitute nuget FluentAssertions nuget Nuget.CommandLine nuget Shouldly - -nuget NLog ~> 4.0 \ No newline at end of file +nuget NLog ~> 4.0 + +#To support .NET framework 4.7.2 (Please don't modify) +nuget System.IO redirects: off +nuget System.IO.Compression redirects: off +nuget System.IO.FileSystem redirects: off +nuget System.Linq redirects: off +nuget System.Linq.Expressions redirects: off +nuget System.Reflection redirects: off +nuget System.Runtime redirects: off +nuget System.Runtime.Extensions redirects: off +nuget System.Runtime.InteropServices redirects: off +nuget System.Runtime.InteropServices.RuntimeInformation redirects: off +nuget System.Xml.ReaderWriter redirects: off +#End of fragment diff --git a/paket.lock b/paket.lock index 3359bd8e..a6c1d653 100644 --- a/paket.lock +++ b/paket.lock @@ -1,13 +1,12 @@ REDIRECTS: ON COPY-CONTENT-TO-OUTPUT-DIR: ALWAYS CONTENT: ONCE -RESTRICTION: == net451 +RESTRICTION: == net472 NUGET remote: https://api.nuget.org/v3/index.json Castle.Core (4.3.1) DataAnnotationsValidator (2.1) - FluentAssertions (5.5.3) - System.ValueTuple (>= 4.4) + FluentAssertions (5.6) Gigya.ServiceContract (2.7.1) Newtonsoft.Json (>= 9.0.1) Metrics.NET (0.5.5) @@ -16,11 +15,47 @@ NUGET Microsoft.Bcl.Async (1.0.168) Microsoft.Bcl (>= 1.1.8) Microsoft.Bcl.Build (1.0.21) - import_targets: false - Microsoft.CodeAnalysis.Analyzers (2.6.2) + Microsoft.CodeAnalysis.Analyzers (2.6.3) Microsoft.CodeAnalysis.Common (1.3.2) Microsoft.CodeAnalysis.Analyzers (>= 1.1) - System.Collections.Immutable (>= 1.1.37) - System.Reflection.Metadata (>= 1.2) + System.AppContext (>= 4.1) + System.Collections (>= 4.0.11) + System.Collections.Concurrent (>= 4.0.12) + System.Collections.Immutable (>= 1.2) + System.Console (>= 4.0) + System.Diagnostics.Debug (>= 4.0.11) + System.Diagnostics.FileVersionInfo (>= 4.0) + System.Diagnostics.StackTrace (>= 4.0.1) + System.Diagnostics.Tools (>= 4.0.1) + System.Dynamic.Runtime (>= 4.0.11) + System.Globalization (>= 4.0.11) + System.IO.FileSystem (>= 4.0.1) + System.IO.FileSystem.Primitives (>= 4.0.1) + System.Linq (>= 4.1) + System.Linq.Expressions (>= 4.1) + System.Reflection (>= 4.1) + System.Reflection.Metadata (>= 1.3) + System.Reflection.Primitives (>= 4.0.1) + System.Resources.ResourceManager (>= 4.0.1) + System.Runtime (>= 4.1) + System.Runtime.Extensions (>= 4.1) + System.Runtime.Handles (>= 4.0.1) + System.Runtime.InteropServices (>= 4.1) + System.Runtime.Numerics (>= 4.0.1) + System.Security.Cryptography.Algorithms (>= 4.2) + System.Security.Cryptography.Encoding (>= 4.0) + System.Security.Cryptography.X509Certificates (>= 4.1) + System.Text.Encoding (>= 4.0.11) + System.Text.Encoding.CodePages (>= 4.0.1) + System.Text.Encoding.Extensions (>= 4.0.11) + System.Threading (>= 4.0.11) + System.Threading.Tasks (>= 4.0.11) + System.Threading.Tasks.Parallel (>= 4.0.1) + System.Threading.Thread (>= 4.0) + System.Xml.ReaderWriter (>= 4.0.11) + System.Xml.XDocument (>= 4.0.11) + System.Xml.XmlDocument (>= 4.0.1) + System.Xml.XPath.XDocument (>= 4.0.1) Microsoft.CodeAnalysis.CSharp (1.3.2) Microsoft.CodeAnalysis.Common (1.3.2) Microsoft.Extensions.DependencyInjection (1.1.1) @@ -29,7 +64,7 @@ NUGET Microsoft.Extensions.DependencyInjection.Abstractions (1.1.1) NETStandard.Library (>= 1.6.1) System.ComponentModel (>= 4.3) - Microsoft.NETCore.Platforms (2.1.2) + Microsoft.NETCore.Platforms (2.2) Microsoft.Orleans.Core (1.3.1) Newtonsoft.Json (>= 7.0.1) System.Collections.Immutable (>= 1.1.37) @@ -57,7 +92,6 @@ NUGET Microsoft.Orleans.OrleansRuntime (>= 1.3.1) NETStandard.Library (2.0.3) Microsoft.NETCore.Platforms (>= 1.1) - System.Runtime.InteropServices.RuntimeInformation (>= 4.3) Newtonsoft.Json (9.0.1) Ninject (3.3.4) Ninject.Extensions.Conventions (3.3) @@ -70,22 +104,72 @@ NUGET Microsoft.Bcl.Async (>= 1.0.168) Microsoft.Bcl.Build (>= 1.0.21) NLog (4.5.11) - NSubstitute (3.1) - Castle.Core (>= 4.2) + NSubstitute (4.0) + Castle.Core (>= 4.3.1) System.Threading.Tasks.Extensions (>= 4.3) - Nuget.CommandLine (4.7.1) + Nuget.CommandLine (4.9.2) NUnit (3.11) RichardSzalay.MockHttp (5.0) Shouldly (3.0.2) + System.AppContext (4.3) + System.Collections (4.3) + System.Collections.Concurrent (4.3) System.Collections.Immutable (1.5) System.ComponentModel (4.3) System.ComponentModel.Annotations (4.5) + System.Console (4.3.1) + System.Diagnostics.Debug (4.3) + System.Diagnostics.FileVersionInfo (4.3) + System.Diagnostics.StackTrace (4.3) + System.Diagnostics.Tools (4.3) + System.Dynamic.Runtime (4.3) + System.Globalization (4.3) + System.IO (4.3) - redirects: off + System.IO.Compression (4.3) - redirects: off + System.IO.FileSystem (4.3) - redirects: off + System.IO.FileSystem.Primitives (>= 4.3) + System.IO.FileSystem.Primitives (4.3) - redirects: off + System.Linq (4.3) - redirects: off + System.Linq.Expressions (4.3) - redirects: off + System.Reflection (4.3) - redirects: off System.Reflection.Metadata (1.6) System.Collections.Immutable (>= 1.5) + System.Reflection.Primitives (4.3) + System.Resources.ResourceManager (4.3) + System.Runtime (4.3.1) - redirects: off System.Runtime.CompilerServices.Unsafe (4.5.2) - System.Runtime.InteropServices.RuntimeInformation (4.3) + System.Runtime.Extensions (4.3) - redirects: off + System.Runtime.Handles (4.3) + System.Runtime.InteropServices (4.3) - redirects: off + System.Runtime (>= 4.3) + System.Runtime.InteropServices.RuntimeInformation (4.3) - redirects: off + System.Runtime.Numerics (4.3) + System.Security.Cryptography.Algorithms (4.3.1) + System.IO (>= 4.3) + System.Runtime (>= 4.3) + System.Security.Cryptography.Encoding (>= 4.3) + System.Security.Cryptography.Primitives (>= 4.3) + System.Security.Cryptography.Encoding (4.3) + System.Security.Cryptography.Primitives (4.3) + System.Security.Cryptography.X509Certificates (4.3.2) + System.Security.Cryptography.Algorithms (>= 4.3) + System.Security.Cryptography.Encoding (>= 4.3) + System.Text.Encoding (4.3) + System.Text.Encoding.CodePages (4.5.1) + System.Runtime.CompilerServices.Unsafe (>= 4.5.2) + System.Text.Encoding.Extensions (4.3) + System.Threading (4.3) + System.Threading.Tasks (4.3) System.Threading.Tasks.Dataflow (4.9) - System.Threading.Tasks.Extensions (4.5.1) - System.Runtime.CompilerServices.Unsafe (>= 4.5) + System.Threading.Tasks.Extensions (4.5.2) + System.Runtime.CompilerServices.Unsafe (>= 4.5.2) + System.Threading.Tasks.Parallel (4.3) + System.Threading.Thread (4.3) System.ValueTuple (4.5) + System.Xml.ReaderWriter (4.3.1) - redirects: off + System.Xml.XDocument (4.3) + System.Xml.XmlDocument (4.3) + System.Xml.XPath (4.3) + System.Xml.XPath.XDocument (4.3) + System.Xml.XPath (>= 4.3) ZooKeeperNetEx (3.4.12) diff --git a/tests/Gigya.Microdot.Hosting.UnitTests/Gigya.Microdot.Hosting.UnitTests.csproj b/tests/Gigya.Microdot.Hosting.UnitTests/Gigya.Microdot.Hosting.UnitTests.csproj index 8e338f0a..99101626 100644 --- a/tests/Gigya.Microdot.Hosting.UnitTests/Gigya.Microdot.Hosting.UnitTests.csproj +++ b/tests/Gigya.Microdot.Hosting.UnitTests/Gigya.Microdot.Hosting.UnitTests.csproj @@ -1,6 +1,7 @@  + Debug @@ -10,7 +11,7 @@ Properties Gigya.Microdot.Hosting.UnitTests Gigya.Microdot.Hosting.UnitTests - v4.5.1 + v4.7.2 512 true @@ -22,7 +23,7 @@ bin\Debug\ DEBUG;TRACE prompt - 4 + 3 CS1998 @@ -52,10 +53,19 @@ - + + Designer + + + + + <__paket__NETStandard_Library_targets>netstandard2.0\NETStandard.Library + + + - + ..\..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -87,7 +80,7 @@ - + ..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -98,7 +91,7 @@ - + ..\..\packages\NUnit\lib\net45\nunit.framework.dll @@ -109,7 +102,7 @@ - + True diff --git a/tests/Gigya.Microdot.ServiceContract.UnitTests/app.config b/tests/Gigya.Microdot.ServiceContract.UnitTests/app.config index f4a16408..535fdb59 100644 --- a/tests/Gigya.Microdot.ServiceContract.UnitTests/app.config +++ b/tests/Gigya.Microdot.ServiceContract.UnitTests/app.config @@ -1,9 +1,9 @@ - + - + True - - + + diff --git a/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/LoadBalancerTests.cs b/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/LoadBalancerTests.cs index 857b13cd..478a845a 100644 --- a/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/LoadBalancerTests.cs +++ b/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/LoadBalancerTests.cs @@ -21,7 +21,6 @@ #endregion using System; -using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using Gigya.Common.Contracts.Exceptions; @@ -29,7 +28,6 @@ using Gigya.Microdot.Interfaces.Logging; using Gigya.Microdot.Interfaces.SystemWrappers; using Gigya.Microdot.ServiceDiscovery; -using Gigya.Microdot.ServiceDiscovery.HostManagement; using Gigya.Microdot.ServiceDiscovery.Rewrite; using Gigya.Microdot.SharedLogic.Monitor; using Gigya.Microdot.SharedLogic.Rewrite; @@ -59,12 +57,12 @@ public class LoadBalancerTests private IDiscovery _discovery; - private Node Node1 = new Node("Host1", 111); - private Node Node2 = new Node("Host2", 222); - private Node Node3 = new Node("Host3", 333); - private Node Node4 = new Node("Host4", 444); - private Node Node5 = new Node("Host5", 555); - private Node Node6 = new Node("Host6", 666); + private readonly Node _node1 = new Node("Host1", 111); + private readonly Node _node2 = new Node("Host2", 222); + private readonly Node _node3 = new Node("Host3", 333); + private readonly Node _node4 = new Node("Host4", 444); + private readonly Node _node5 = new Node("Host5", 555); + private readonly Node _node6 = new Node("Host6", 666); private Func _getSourceNodes = () => new Node[0]; private IEnvironment _environment; @@ -112,10 +110,10 @@ public async Task GetNode_RoutingTrafficRoundRobin_GetDiffenent3NodesAfterExactl { CreateLoadBalancer(TrafficRoutingStrategy.RoundRobin); SetupDefaultNodes(); - var allEndpoints = await GetNodes(times:3); - allEndpoints.ShouldContain(Node1); - allEndpoints.ShouldContain(Node2); - allEndpoints.ShouldContain(Node3); + var allEndpoints = await GetNodes(3); + allEndpoints.ShouldContain(_node1); + allEndpoints.ShouldContain(_node2); + allEndpoints.ShouldContain(_node3); } [Test] @@ -126,7 +124,7 @@ public async Task GetNode_ThreeNodes_ReturnsAllThree() var allEndpoints = await Get20Nodes(); - new[] { Node1, Node2, Node3 }.ShouldBeSubsetOf(allEndpoints); + new[] { _node1, _node2, _node3 }.ShouldBeSubsetOf(allEndpoints); } [Test] @@ -145,14 +143,14 @@ public void GetNode_ThreeNodes_ShouldBeHealthy() public async Task GetNode_NodesChanged_ReturnsNewNodes() { CreateLoadBalancer(); - SetupSourceNodes(Node1,Node2,Node3); + SetupSourceNodes(_node1,_node2,_node3); Get20Nodes(); - SetupSourceNodes(Node4, Node5, Node6); + SetupSourceNodes(_node4, _node5, _node6); var res = await Get20Nodes(); res.Distinct() - .ShouldBe(new[] { Node4, Node5, Node6 }, true); + .ShouldBe(new[] { _node4, _node5, _node6 }, true); } [Test] @@ -181,7 +179,7 @@ public void GetNode_NodesListBecomesEmpty_Throws() public async Task GetNode_AfterNodeReportedUnreachable_NodeWillNotBeReturned() { CreateLoadBalancer(); - var allNodes = new[] {Node1, Node2, Node3}; + var allNodes = new[] {_node1, _node2, _node3}; SetupSourceNodes(allNodes); var unreachableNode = await _loadBalancer.TryGetNode(); @@ -197,6 +195,49 @@ public async Task GetNode_AfterNodeReportedUnreachable_NodeWillNotBeReturned() } } + [Test] + [Repeat(Repeat)] + public async Task GetNode_TwoNodesUnreachable_OneBecomesReachable_ReturnOnlyReachableNode() + { + Node nodeToBeUnreachable = null; + + _reachabilityCheck = async (n, c) => + { + // ReSharper disable once AccessToModifiedClosure + if (Equals(n, nodeToBeUnreachable)) throw new Exception("This node is still unreachable"); + }; + CreateLoadBalancer(); + + var allNodes = new[] { _node1, _node2, _node3 }; + SetupSourceNodes(allNodes); + + nodeToBeUnreachable = await _loadBalancer.TryGetNode(); + var nodeToBeReachable = await GetDifferentNode(nodeToBeUnreachable); + + _loadBalancer.ReportUnreachable(nodeToBeReachable); + _loadBalancer.ReportUnreachable(nodeToBeUnreachable); + + await Task.Delay(1000); + + var nodes = await Get20Nodes(); + foreach (var node in allNodes) + { + if (node.Equals(nodeToBeUnreachable)) + nodes.ShouldNotContain(node); + else + nodes.ShouldContain(node); + } + } + + private async Task GetDifferentNode(Node nodeToCompare) + { + var differentNode = nodeToCompare; + while (Equals(differentNode, nodeToCompare)) + differentNode = await _loadBalancer.TryGetNode(); + + return differentNode; + } + [Test] [Repeat(Repeat)] public async Task GetNode_NodeIsReachableAgain_NodeWillBeReturned() @@ -222,21 +263,21 @@ public async Task GetNode_OnlyOneNodeUnreachable_ShouldStillBeHealthy() CreateLoadBalancer(); SetupDefaultNodes(); - await Run20times(node => + await Run20Times(node => { - if (node.Equals(Node2)) + if (node.Equals(_node2)) _loadBalancer.ReportUnreachable(node); }); var healthResult = GetHealthStatus(); healthResult.IsHealthy.ShouldBeTrue(); - healthResult.Message.ShouldContain(Node2.ToString()); + healthResult.Message.ShouldContain(_node2.ToString()); } - private async Task Run20times(Action act) + private async Task Run20Times(Action act) { - for (int i = 0; i < 20; i++) + for (var i = 0; i < 20; i++) { try { @@ -245,6 +286,7 @@ private async Task Run20times(Action act) } catch { + // ignored } } } @@ -279,17 +321,17 @@ public async Task GetNode_NodeUnreachableThenReturnsInBackground_NodeShouldBeRet public async Task GetNode_AllNodesUnreachable_ThrowsException() { CreateLoadBalancer(); - SetupSourceNodes(Node1,Node2,Node3); + SetupSourceNodes(_node1,_node2,_node3); - await Run20times(node =>_loadBalancer.ReportUnreachable(node)); + await Run20Times(node =>_loadBalancer.ReportUnreachable(node)); Should.Throw(() => _loadBalancer.TryGetNode()); var healthStatus = GetHealthStatus(); healthStatus.IsHealthy.ShouldBeFalse(healthStatus.Message); healthStatus.Message.ShouldContain("All 3 Nodes are unreachable"); - healthStatus.Message.ShouldContain(Node1.ToString()); - healthStatus.Message.ShouldContain(Node2.ToString()); - healthStatus.Message.ShouldContain(Node3.ToString()); + healthStatus.Message.ShouldContain(_node1.ToString()); + healthStatus.Message.ShouldContain(_node2.ToString()); + healthStatus.Message.ShouldContain(_node3.ToString()); } [Test] @@ -297,8 +339,8 @@ public async Task GetNode_AllNodesUnreachable_ThrowsException() public async Task GetNode_AllNodesUnreachableThenAllNodesReachable_ReturnsAllNodes() { CreateLoadBalancer(); - SetupSourceNodes(Node1,Node2,Node3); - await Run20times(node => _loadBalancer.ReportUnreachable(node)); + SetupSourceNodes(_node1, _node2, _node3); + await Run20Times(node => _loadBalancer.ReportUnreachable(node)); Should.Throw(() => _loadBalancer.TryGetNode()); @@ -307,9 +349,9 @@ public async Task GetNode_AllNodesUnreachableThenAllNodesReachable_ReturnsAllNod await Task.Delay(1000); var nodes = await Get20Nodes(); - nodes.ShouldContain(Node1); - nodes.ShouldContain(Node2); - nodes.ShouldContain(Node3); + nodes.ShouldContain(_node1); + nodes.ShouldContain(_node2); + nodes.ShouldContain(_node3); } @@ -321,8 +363,8 @@ public async Task GetNode_NodesUnreachableButReachabilityCheckThrows_ErrorIsLogg SetupDefaultNodes(); var reachabilityException = new Exception("Simulated error while running reachability check"); - _reachabilityCheck = (_,__) => { throw reachabilityException; }; - await Run20times(node => _loadBalancer.ReportUnreachable(node)); + _reachabilityCheck = (_,__) => throw reachabilityException; + await Run20Times(node => _loadBalancer.ReportUnreachable(node)); await Task.Delay(1500); @@ -356,17 +398,18 @@ private void SetupErrorGettingNodes(Exception ex) private void SetupDefaultNodes() { - SetupSourceNodes(Node1, Node2, Node3); + SetupSourceNodes(_node1, _node2, _node3); } - async Task GetNodes(int times) + private async Task GetNodes(int times) { var tasks = Enumerable.Repeat(1, times).Select(_ => _loadBalancer.TryGetNode()); - await Task.WhenAll(tasks); - return tasks.Select(t => t.Result).ToArray(); + var enumerable = tasks as Task[] ?? tasks.ToArray(); + await Task.WhenAll(enumerable); + return enumerable.Select(t => t.Result).ToArray(); } - Task Get20Nodes() + private Task Get20Nodes() { return GetNodes(20); } @@ -377,5 +420,4 @@ private HealthCheckResult GetHealthStatus() return healthMonitor.Monitors[ServiceName].Invoke(); } } - } diff --git a/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/MultiEnvironmentServiceDiscoveryPreferredEnvironmentTests.cs b/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/MultiEnvironmentServiceDiscoveryPreferredEnvironmentTests.cs index 5a16f4ad..62ba9d73 100644 --- a/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/MultiEnvironmentServiceDiscoveryPreferredEnvironmentTests.cs +++ b/tests/Gigya.Microdot.UnitTests/Discovery/Rewrite/MultiEnvironmentServiceDiscoveryPreferredEnvironmentTests.cs @@ -71,6 +71,8 @@ public async Task Setup() public void TearDown() { _unitTestingKernel.Dispose(); + _loadBalancerByEnvironment.Clear(); + _serviceDiscovery = null; } [Test] diff --git a/tests/Gigya.Microdot.UnitTests/Gigya.Microdot.UnitTests.csproj b/tests/Gigya.Microdot.UnitTests/Gigya.Microdot.UnitTests.csproj index 034c4f19..3fcf7b46 100644 --- a/tests/Gigya.Microdot.UnitTests/Gigya.Microdot.UnitTests.csproj +++ b/tests/Gigya.Microdot.UnitTests/Gigya.Microdot.UnitTests.csproj @@ -10,9 +10,10 @@ Properties Gigya.Microdot.UnitTests Gigya.Microdot.UnitTests - v4.5.1 + v4.7.2 512 true + true @@ -21,7 +22,7 @@ bin\Debug\ TRACE;DEBUG prompt - 4 + 3 CS4014;CS1998; @@ -94,6 +95,7 @@ + @@ -118,7 +120,9 @@ - + + Designer + PreserveNewest @@ -205,7 +209,7 @@ - + True @@ -219,7 +223,7 @@ - + True @@ -233,10 +237,10 @@ - + - ..\..\packages\FluentAssertions\lib\net45\FluentAssertions.dll + ..\..\packages\FluentAssertions\lib\net47\FluentAssertions.dll True True @@ -244,7 +248,7 @@ - + ..\..\packages\Gigya.ServiceContract\lib\net451\Gigya.ServiceContract.dll @@ -255,7 +259,7 @@ - + ..\..\packages\Metrics.NET\lib\net45\Metrics.dll @@ -266,7 +270,7 @@ - + ..\..\packages\Microsoft.Orleans.Core\lib\net451\Orleans.dll @@ -277,7 +281,7 @@ - + ..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll @@ -288,7 +292,7 @@ - + ..\..\packages\Ninject\lib\net45\Ninject.dll @@ -299,10 +303,10 @@ - + - ..\..\packages\NSubstitute\lib\net45\NSubstitute.dll + ..\..\packages\NSubstitute\lib\net46\NSubstitute.dll True True @@ -310,7 +314,7 @@ - + ..\..\packages\NUnit\lib\net45\nunit.framework.dll @@ -321,7 +325,7 @@ - + ..\..\packages\RichardSzalay.MockHttp\lib\net45\RichardSzalay.MockHttp.dll @@ -332,7 +336,7 @@ - + ..\..\packages\Shouldly\lib\net451\Shouldly.dll @@ -343,10 +347,10 @@ - + - ..\..\packages\System.Collections.Immutable\lib\netstandard1.0\System.Collections.Immutable.dll + ..\..\packages\System.Collections.Immutable\lib\netstandard2.0\System.Collections.Immutable.dll True True @@ -354,10 +358,13 @@ - + - - ..\..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll + + True + + + ..\..\packages\System.ComponentModel.Annotations\lib\net461\System.ComponentModel.Annotations.dll True True @@ -365,10 +372,10 @@ - + - - ..\..\packages\System.Threading.Tasks.Dataflow\lib\netstandard1.1\System.Threading.Tasks.Dataflow.dll + + ..\..\packages\System.Runtime.CompilerServices.Unsafe\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll True True @@ -376,10 +383,10 @@ - + - - ..\..\packages\System.Threading.Tasks.Extensions\lib\netstandard1.0\System.Threading.Tasks.Extensions.dll + + ..\..\packages\System.Threading.Tasks.Dataflow\lib\netstandard2.0\System.Threading.Tasks.Dataflow.dll True True @@ -387,10 +394,10 @@ - + - - ..\..\packages\System.ValueTuple\lib\netstandard1.0\System.ValueTuple.dll + + ..\..\packages\System.Threading.Tasks.Extensions\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll True True diff --git a/tests/Gigya.Microdot.UnitTests/RequestOverridesTests.cs b/tests/Gigya.Microdot.UnitTests/RequestOverridesTests.cs new file mode 100644 index 00000000..04838cd3 --- /dev/null +++ b/tests/Gigya.Microdot.UnitTests/RequestOverridesTests.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.Linq; +using Gigya.Microdot.SharedLogic.HttpService; +using NUnit.Framework; + +namespace Gigya.Microdot.UnitTests +{ + [TestFixture()] + public class RequestOverridesTests + { + [Test] + public void CheckRequestOverridesShallowClone() + { + RequestOverrides ro = new RequestOverrides(); + HostOverride ho1 = new HostOverride{Host = "testHost1", Port = 1234, ServiceName = "testService1"}; + ho1.AdditionalProperties = new Dictionary(); + ho1.AdditionalProperties.Add("ho1Key", "ho1Value"); + + HostOverride ho2 = new HostOverride{ Host = "testHost2", Port = 1235, ServiceName = "testService2"}; + ho2.AdditionalProperties = new Dictionary(); + ho2.AdditionalProperties.Add("ho2Key", "ho2Value"); + + ro.Hosts = new List(new []{ho1, ho2}); + ro.PreferredEnvironment = "pe1"; + ro.AdditionalProperties = new Dictionary(); + ro.AdditionalProperties.Add("roKey", "roValue"); + + RequestOverrides roResult = ro.ShallowCloneWithDifferentPreferredEnvironment("pe2"); + + Assert.AreEqual(ro.Hosts.Count, roResult.Hosts.Count); + Assert.AreEqual(ro.Hosts.Join(roResult.Hosts, h => new {h.Host, h.Port, h.ServiceName}, hr => new {hr.Host, hr.Port, hr.ServiceName}, (h, hr) => hr).Count(), roResult.Hosts.Count); + Assert.AreEqual(roResult.Hosts[0].AdditionalProperties["ho1Key"], "ho1Value"); + Assert.AreEqual(roResult.Hosts[1].AdditionalProperties["ho2Key"], "ho2Value"); + Assert.AreEqual(roResult.AdditionalProperties["roKey"], "roValue"); + Assert.AreEqual(ro.PreferredEnvironment, "pe1"); + Assert.AreEqual(roResult.PreferredEnvironment, "pe2"); + } + } +} diff --git a/tests/Gigya.Microdot.UnitTests/ServiceProxyTests/AbstractServiceProxyTest.cs b/tests/Gigya.Microdot.UnitTests/ServiceProxyTests/AbstractServiceProxyTest.cs index 2e385f6e..f19b6b82 100644 --- a/tests/Gigya.Microdot.UnitTests/ServiceProxyTests/AbstractServiceProxyTest.cs +++ b/tests/Gigya.Microdot.UnitTests/ServiceProxyTests/AbstractServiceProxyTest.cs @@ -49,7 +49,7 @@ public virtual void TearDown() protected IDemoService CreateClient(HttpMessageHandler mockHttpMessageHandler = null) { return unitTesting - .Get>(new ConstructorArgument("httpMessageHandler", mockHttpMessageHandler ?? new WebRequestHandler())) + .Get>(new ConstructorArgument("httpMessageHandler", mockHttpMessageHandler ?? new HttpClientHandler())) .Client; } } diff --git a/tests/Gigya.Microdot.UnitTests/app.config b/tests/Gigya.Microdot.UnitTests/app.config index ae058b20..f5776235 100644 --- a/tests/Gigya.Microdot.UnitTests/app.config +++ b/tests/Gigya.Microdot.UnitTests/app.config @@ -1,6 +1,6 @@  - + True @@ -36,21 +36,11 @@ - - True - - - True - - True - - - True