diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9c4ec4c5d..1055b7256 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,15 @@ -### New in 0.43 (not released yet) +### New in 0.44 (not released yet) + +* New: .NET Standard 1.6 support for the following NuGet packages + - `EventFlow` + - `EventFlow.Autofac` + - `EventFlow.Elasticsearch` + - `EventFlow.Hangfire` + - `EventFlow.RabbitMQ` +* Fixed: Removed dependency `Microsoft.Owin.Host.HttpListener` from + `EventFlow.Owin` as it doesn't need it + +### New in 0.43.2806 (released 2017-05-05) * Breaking: Updated _all_ NuGet package dependencies to their latest versions * New: EventFlow now embeds PDB and source code within the assemblies using diff --git a/Source/EventFlow.Autofac/EventFlow.Autofac.csproj b/Source/EventFlow.Autofac/EventFlow.Autofac.csproj index 7f3bc74f5..6a2fd44e1 100644 --- a/Source/EventFlow.Autofac/EventFlow.Autofac.csproj +++ b/Source/EventFlow.Autofac/EventFlow.Autofac.csproj @@ -1,7 +1,7 @@  - net451 + net451;netstandard1.6 True True False diff --git a/Source/EventFlow.Elasticsearch/EventFlow.Elasticsearch.csproj b/Source/EventFlow.Elasticsearch/EventFlow.Elasticsearch.csproj index e904e8438..399bb3768 100644 --- a/Source/EventFlow.Elasticsearch/EventFlow.Elasticsearch.csproj +++ b/Source/EventFlow.Elasticsearch/EventFlow.Elasticsearch.csproj @@ -1,7 +1,7 @@  - net451 + net451;netstandard1.6 True True False diff --git a/Source/EventFlow.Elasticsearch/ReadStores/ReadModelDescriptionProvider.cs b/Source/EventFlow.Elasticsearch/ReadStores/ReadModelDescriptionProvider.cs index 66fc3b110..b533d4fd4 100644 --- a/Source/EventFlow.Elasticsearch/ReadStores/ReadModelDescriptionProvider.cs +++ b/Source/EventFlow.Elasticsearch/ReadStores/ReadModelDescriptionProvider.cs @@ -42,7 +42,7 @@ public ReadModelDescription GetReadModelDescription() where TReadMod typeof(TReadModel), t => { - var elasticType = t.GetCustomAttribute(); + var elasticType = t.GetTypeInfo().GetCustomAttribute(); var indexName = elasticType == null ? $"eventflow-{typeof(TReadModel).PrettyPrint().ToLowerInvariant()}" : elasticType.Name; diff --git a/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj b/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj index c8ee4b843..5a837f4b2 100644 --- a/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj +++ b/Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj @@ -1,7 +1,7 @@  - net451 + net451;netstandard1.6 True True False diff --git a/Source/EventFlow.Owin.Tests/EventFlow.Owin.Tests.csproj b/Source/EventFlow.Owin.Tests/EventFlow.Owin.Tests.csproj index 245d50206..30aa06e8d 100644 --- a/Source/EventFlow.Owin.Tests/EventFlow.Owin.Tests.csproj +++ b/Source/EventFlow.Owin.Tests/EventFlow.Owin.Tests.csproj @@ -11,6 +11,7 @@ + diff --git a/Source/EventFlow.Owin/EventFlow.Owin.csproj b/Source/EventFlow.Owin/EventFlow.Owin.csproj index c99a56499..d078303d9 100644 --- a/Source/EventFlow.Owin/EventFlow.Owin.csproj +++ b/Source/EventFlow.Owin/EventFlow.Owin.csproj @@ -25,7 +25,6 @@ - diff --git a/Source/EventFlow.RabbitMQ/EventFlow.RabbitMQ.csproj b/Source/EventFlow.RabbitMQ/EventFlow.RabbitMQ.csproj index d39cdd0fe..bc3f49be9 100644 --- a/Source/EventFlow.RabbitMQ/EventFlow.RabbitMQ.csproj +++ b/Source/EventFlow.RabbitMQ/EventFlow.RabbitMQ.csproj @@ -1,7 +1,7 @@  - net451 + net451;netstandard1.6 True True False diff --git a/Source/EventFlow.RabbitMQ/Integrations/RabbitMqConnectionFactory.cs b/Source/EventFlow.RabbitMQ/Integrations/RabbitMqConnectionFactory.cs index 4cd327f23..d073a2a38 100644 --- a/Source/EventFlow.RabbitMQ/Integrations/RabbitMqConnectionFactory.cs +++ b/Source/EventFlow.RabbitMQ/Integrations/RabbitMqConnectionFactory.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Core; @@ -73,7 +74,7 @@ private async Task CreateConnectionFactoryAsync(Uri uri, Canc AutomaticRecoveryEnabled = true, ClientProperties = new Dictionary { - { "eventflow-version", typeof(RabbitMqConnectionFactory).Assembly.GetName().Version.ToString() }, + { "eventflow-version", typeof(RabbitMqConnectionFactory).GetTypeInfo().Assembly.GetName().Version.ToString() }, { "machine-name", Environment.MachineName }, }, }; diff --git a/Source/EventFlow/CommandBus.cs b/Source/EventFlow/CommandBus.cs index 6941f8ab9..51d107a29 100644 --- a/Source/EventFlow/CommandBus.cs +++ b/Source/EventFlow/CommandBus.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; @@ -154,9 +155,10 @@ private Task GetCommandExecutionDetailsAsync(Type comma _ => { var commandInterfaceType = commandType + .GetTypeInfo() .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommand<,,>)); - var commandTypes = commandInterfaceType.GetGenericArguments(); + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommand<,,>)); + var commandTypes = commandInterfaceType.GetTypeInfo().GetGenericArguments(); var commandHandlerType = typeof(ICommandHandler<,,,>) .MakeGenericType(commandTypes[0], commandTypes[1], commandTypes[2], commandType); diff --git a/Source/EventFlow/Configuration/Decorators/DecoratorService.cs b/Source/EventFlow/Configuration/Decorators/DecoratorService.cs index 93130e9ed..d14251d15 100644 --- a/Source/EventFlow/Configuration/Decorators/DecoratorService.cs +++ b/Source/EventFlow/Configuration/Decorators/DecoratorService.cs @@ -25,6 +25,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection; namespace EventFlow.Configuration.Decorators { @@ -40,6 +41,7 @@ public object Decorate(Type serviceType, object implementation, IResolverContext t => { var genericMethodInfo = GetType() + .GetTypeInfo() .GetMethods() .Single(mi => mi.IsGenericMethodDefinition && mi.Name == "Decorate"); var methodInfo = genericMethodInfo.MakeGenericMethod(t); diff --git a/Source/EventFlow/Core/Caching/MemoryCache.cs b/Source/EventFlow/Core/Caching/MemoryCache.cs index 0a7b0252c..a4291d61a 100644 --- a/Source/EventFlow/Core/Caching/MemoryCache.cs +++ b/Source/EventFlow/Core/Caching/MemoryCache.cs @@ -21,6 +21,8 @@ // 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. +#if NET451 + using System; using System.Runtime.Caching; using System.Threading; @@ -88,4 +90,6 @@ protected override Task GetAsync( return Task.FromResult(value); } } -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Source/EventFlow/Core/GuidFactories.cs b/Source/EventFlow/Core/GuidFactories.cs index 520413009..133a94d4b 100644 --- a/Source/EventFlow/Core/GuidFactories.cs +++ b/Source/EventFlow/Core/GuidFactories.cs @@ -116,9 +116,11 @@ public static Guid Create(Guid namespaceId, byte[] nameBytes) byte[] hash; using (var algorithm = SHA1.Create()) { - algorithm.TransformBlock(namespaceBytes, 0, namespaceBytes.Length, null, 0); - algorithm.TransformFinalBlock(nameBytes, 0, nameBytes.Length); - hash = algorithm.Hash; + var combinedBytes = new byte[namespaceBytes.Length + nameBytes.Length]; + Buffer.BlockCopy(namespaceBytes, 0, combinedBytes, 0, namespaceBytes.Length); + Buffer.BlockCopy(nameBytes, 0, combinedBytes, namespaceBytes.Length, nameBytes.Length); + + hash = algorithm.ComputeHash(combinedBytes); } // Most bytes from the hash are copied straight to the bytes of the new diff --git a/Source/EventFlow/Core/Identity.cs b/Source/EventFlow/Core/Identity.cs index d1a2483c3..800c9592b 100644 --- a/Source/EventFlow/Core/Identity.cs +++ b/Source/EventFlow/Core/Identity.cs @@ -103,7 +103,7 @@ public static IEnumerable Validate(string value) yield break; } - if (!string.Equals(value.Trim(), value, StringComparison.InvariantCulture)) + if (!string.Equals(value.Trim(), value, StringComparison.OrdinalIgnoreCase)) yield return $"Identity '{value}' of type '{typeof(T).PrettyPrint()}' contains leading and/or traling spaces"; if (!value.StartsWith(Name)) yield return $"Identity '{value}' of type '{typeof(T).PrettyPrint()}' does not start with '{Name}'"; diff --git a/Source/EventFlow/Core/IoC/EventFlowIoCResolver.cs b/Source/EventFlow/Core/IoC/EventFlowIoCResolver.cs index 5ad9c9012..efdbc1240 100644 --- a/Source/EventFlow/Core/IoC/EventFlowIoCResolver.cs +++ b/Source/EventFlow/Core/IoC/EventFlowIoCResolver.cs @@ -24,7 +24,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Configuration; using System.Linq; using System.Reflection; using EventFlow.Configuration; @@ -60,7 +59,7 @@ public object Resolve(Type serviceType) var genericArguments = _emptyTypeArray; var typeInfo = serviceType.GetTypeInfo(); - if (serviceType.IsGenericType && + if (typeInfo.IsGenericType && !_registrations.ContainsKey(serviceType) && typeInfo.GetGenericTypeDefinition() != typeof(IEnumerable<>)) { @@ -88,7 +87,7 @@ public object Resolve(Type serviceType) .Create(_resolverContext); } - throw new ConfigurationErrorsException($"Type {serviceType.PrettyPrint()} is not registered"); + throw new Exception($"Type {serviceType.PrettyPrint()} is not registered"); } return registrations.First().Create(_resolverContext, genericArguments); @@ -107,7 +106,7 @@ public IEnumerable ResolveAll(Type serviceType) public IEnumerable GetRegisteredServices() { return _registrations.Keys - .Where(t => !t.IsGenericTypeDefinition); + .Where(t => !t.GetTypeInfo().IsGenericTypeDefinition); } public bool HasRegistrationFor() diff --git a/Source/EventFlow/Core/IoC/Factories/ConstructorFactory.cs b/Source/EventFlow/Core/IoC/Factories/ConstructorFactory.cs index ac1081c62..7c8b47259 100644 --- a/Source/EventFlow/Core/IoC/Factories/ConstructorFactory.cs +++ b/Source/EventFlow/Core/IoC/Factories/ConstructorFactory.cs @@ -23,7 +23,6 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Linq; using System.Reflection; using EventFlow.Configuration; @@ -44,7 +43,7 @@ public ConstructorFactory(Type serviceType) if (constructorInfos.Length > 1) { - throw new ConfigurationErrorsException($"Type {serviceType.PrettyPrint()} has more than one constructor"); + throw new Exception($"Type {serviceType.PrettyPrint()} has more than one constructor"); } _constructorInfo = constructorInfos.Single(); diff --git a/Source/EventFlow/Core/IoC/Factories/GenericFactory.cs b/Source/EventFlow/Core/IoC/Factories/GenericFactory.cs index 2e4d50dcd..c0d84a932 100644 --- a/Source/EventFlow/Core/IoC/Factories/GenericFactory.cs +++ b/Source/EventFlow/Core/IoC/Factories/GenericFactory.cs @@ -22,7 +22,6 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System; -using System.Configuration; using System.Linq; using System.Reflection; using EventFlow.Configuration; @@ -42,7 +41,7 @@ public GenericFactory(Type serviceType) if (constructorInfos.Length > 1) { - throw new ConfigurationErrorsException($"Type {serviceType.PrettyPrint()} has more than one constructor"); + throw new Exception($"Type {serviceType.PrettyPrint()} has more than one constructor"); } _serviceType = serviceType; @@ -51,7 +50,7 @@ public GenericFactory(Type serviceType) public object Create(IResolverContext resolverContext, Type[] genericTypeArguments) { var genericType = _serviceType.MakeGenericType(genericTypeArguments); - var constructorInfo = genericType.GetConstructors().Single(); + var constructorInfo = genericType.GetTypeInfo().GetConstructors().Single(); var parameterInfos = constructorInfo.GetParameters(); var parameters = new object[parameterInfos.Length]; diff --git a/Source/EventFlow/Core/IoC/Registration.cs b/Source/EventFlow/Core/IoC/Registration.cs index 96973641c..2e6a989e3 100644 --- a/Source/EventFlow/Core/IoC/Registration.cs +++ b/Source/EventFlow/Core/IoC/Registration.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using EventFlow.Configuration; using EventFlow.Configuration.Decorators; @@ -52,7 +53,7 @@ public Registration( public object Create(IResolverContext resolverContext, Type[] genericTypeArguments) { - var serviceType = genericTypeArguments.Any() && _serviceType.IsGenericType + var serviceType = genericTypeArguments.Any() && _serviceType.GetTypeInfo().IsGenericType ? _serviceType.MakeGenericType(genericTypeArguments) : _serviceType; diff --git a/Source/EventFlow/Core/IoC/ServiceRegistration.cs b/Source/EventFlow/Core/IoC/ServiceRegistration.cs index 0669ff918..290a257f4 100644 --- a/Source/EventFlow/Core/IoC/ServiceRegistration.cs +++ b/Source/EventFlow/Core/IoC/ServiceRegistration.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; +using System.Reflection; using EventFlow.Configuration; namespace EventFlow.Core.IoC @@ -35,7 +36,7 @@ protected static IReadOnlyCollection OrderBootstraps(IEnumerable new { Bootstrap = b, - AssemblyName = b.GetType().Assembly.GetName().Name, + AssemblyName = b.GetType().GetTypeInfo().Assembly.GetName().Name, }) .ToList(); var eventFlowBootstraps = list diff --git a/Source/EventFlow/Core/ReflectionHelper.cs b/Source/EventFlow/Core/ReflectionHelper.cs index 3d065c8f9..67e707f61 100644 --- a/Source/EventFlow/Core/ReflectionHelper.cs +++ b/Source/EventFlow/Core/ReflectionHelper.cs @@ -35,7 +35,7 @@ public static class ReflectionHelper { public static string GetCodeBase(Assembly assembly, bool includeFileName = false) { - var codebase = assembly.GetName().CodeBase; + var codebase = assembly.CodeBase; var uri = new UriBuilder(codebase); var path = Path.GetFullPath(Uri.UnescapeDataString(uri.Path)); var codeBase = includeFileName ? @@ -50,16 +50,18 @@ public static string GetCodeBase(Assembly assembly, bool includeFileName = false /// public static TResult CompileMethodInvocation(Type type, string methodName, params Type[] methodSignature) { + var typeInfo = type.GetTypeInfo(); + var methodInfo = methodSignature == null || !methodSignature.Any() - ? type.GetMethods(BindingFlags.Instance | BindingFlags.Public).SingleOrDefault(m => m.Name == methodName) - : type.GetMethod(methodName, methodSignature); + ? typeInfo.GetMethods(BindingFlags.Instance | BindingFlags.Public).SingleOrDefault(m => m.Name == methodName) + : typeInfo.GetMethod(methodName, methodSignature); if (methodInfo == null) { throw new ArgumentException($"Type '{type.PrettyPrint()}' doesn't have a method called '{methodName}'"); } - var genericArguments = typeof(TResult).GetGenericArguments(); + var genericArguments = typeof(TResult).GetTypeInfo().GetGenericArguments(); var methodArgumentList = methodInfo.GetParameters().Select(p => p.ParameterType).ToList(); var funcArgumentList = genericArguments.Skip(1).Take(methodArgumentList.Count).ToList(); diff --git a/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinition.cs b/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinition.cs index 734c40822..5e2366497 100644 --- a/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinition.cs +++ b/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinition.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using EventFlow.Extensions; using EventFlow.ValueObjects; @@ -46,7 +47,7 @@ protected VersionedTypeDefinition( public override string ToString() { - var assemblyName = Type.Assembly.GetName(); + var assemblyName = Type.GetTypeInfo().Assembly.GetName(); return $"{Name} v{Version} ({assemblyName.Name} - {Type.PrettyPrint()})"; } diff --git a/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinitionService.cs b/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinitionService.cs index a21e39a44..1ab455f19 100644 --- a/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinitionService.cs +++ b/Source/EventFlow/Core/VersionedTypes/VersionedTypeDefinitionService.cs @@ -65,8 +65,7 @@ public void Load(IReadOnlyCollection types) } var invalidTypes = types - .Where(t => !typeof(TTypeCheck) - .IsAssignableFrom(t)) + .Where(t => !typeof(TTypeCheck).GetTypeInfo().IsAssignableFrom(t)) .ToList(); if (invalidTypes.Any()) { @@ -88,7 +87,7 @@ public void Load(IReadOnlyCollection types) _log.Verbose(() => { var assemblies = definitions - .Select(d => d.Type.Assembly.GetName().Name) + .Select(d => d.Type.GetTypeInfo().Assembly.GetName().Name) .Distinct() .OrderBy(n => n) .ToList(); @@ -229,6 +228,7 @@ private TDefinition CreateDefinitionFromName(Type versionedType) private TDefinition CreateDefinitionFromAttribute(Type versionedType) { var attribute = versionedType + .GetTypeInfo() .GetCustomAttributes() .OfType() .SingleOrDefault(); diff --git a/Source/EventFlow/Core/VersionedTypes/VersionedTypeUpgradeService.cs b/Source/EventFlow/Core/VersionedTypes/VersionedTypeUpgradeService.cs index e8e96525c..3b859b87f 100644 --- a/Source/EventFlow/Core/VersionedTypes/VersionedTypeUpgradeService.cs +++ b/Source/EventFlow/Core/VersionedTypes/VersionedTypeUpgradeService.cs @@ -23,6 +23,7 @@ using System; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Configuration; @@ -96,7 +97,7 @@ private async Task UpgradeToVersionAsync( var versionedTypeUpgraderType = typeof(IVersionedTypeUpgrader<,>).MakeGenericType(fromDefinition.Type, toDefinition.Type); var versionedTypeUpgrader = _resolver.Resolve(upgraderType); - var methodInfo = versionedTypeUpgraderType.GetMethod("UpgradeAsync"); + var methodInfo = versionedTypeUpgraderType.GetTypeInfo().GetMethod("UpgradeAsync"); var task = (Task) methodInfo.Invoke(versionedTypeUpgrader, new object[] { versionedType, cancellationToken }); diff --git a/Source/EventFlow/EventFlow.csproj b/Source/EventFlow/EventFlow.csproj index 668dd2e1d..c9b900320 100644 --- a/Source/EventFlow/EventFlow.csproj +++ b/Source/EventFlow/EventFlow.csproj @@ -1,7 +1,7 @@  - net451 + net451;netstandard1.6 True True False @@ -28,7 +28,8 @@ - + + \ No newline at end of file diff --git a/Source/EventFlow/EventFlowOptions.cs b/Source/EventFlow/EventFlowOptions.cs index 1b497d83c..249d9a630 100644 --- a/Source/EventFlow/EventFlowOptions.cs +++ b/Source/EventFlow/EventFlowOptions.cs @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using EventFlow.Aggregates; using EventFlow.Commands; using EventFlow.Configuration; @@ -93,7 +94,7 @@ public IEventFlowOptions AddEvents(IEnumerable aggregateEventTypes) { foreach (var aggregateEventType in aggregateEventTypes) { - if (!typeof(IAggregateEvent).IsAssignableFrom(aggregateEventType)) + if (!typeof(IAggregateEvent).GetTypeInfo().IsAssignableFrom(aggregateEventType)) { throw new ArgumentException($"Type {aggregateEventType.PrettyPrint()} is not a {typeof(IAggregateEvent).PrettyPrint()}"); } @@ -106,7 +107,7 @@ public IEventFlowOptions AddSagas(IEnumerable sagaTypes) { foreach (var sagaType in sagaTypes) { - if (!typeof(ISaga).IsAssignableFrom(sagaType)) + if (!typeof(ISaga).GetTypeInfo().IsAssignableFrom(sagaType)) { throw new ArgumentException($"Type {sagaType.PrettyPrint()} is not a {typeof(ISaga).PrettyPrint()}"); } @@ -119,7 +120,7 @@ public IEventFlowOptions AddCommands(IEnumerable commandTypes) { foreach (var commandType in commandTypes) { - if (!typeof(ICommand).IsAssignableFrom(commandType)) + if (!typeof(ICommand).GetTypeInfo().IsAssignableFrom(commandType)) { throw new ArgumentException($"Type {commandType.PrettyPrint()} is not a {typeof(ICommand).PrettyPrint()}"); } @@ -132,7 +133,7 @@ public IEventFlowOptions AddJobs(IEnumerable jobTypes) { foreach (var jobType in jobTypes) { - if (!typeof(IJob).IsAssignableFrom(jobType)) + if (!typeof(IJob).GetTypeInfo().IsAssignableFrom(jobType)) { throw new ArgumentException($"Type {jobType.PrettyPrint()} is not a {typeof(IJob).PrettyPrint()}"); } @@ -145,7 +146,7 @@ public IEventFlowOptions AddSnapshots(IEnumerable snapshotTypes) { foreach (var snapshotType in snapshotTypes) { - if (!typeof(ISnapshot).IsAssignableFrom(snapshotType)) + if (!typeof(ISnapshot).GetTypeInfo().IsAssignableFrom(snapshotType)) { throw new ArgumentException($"Type {snapshotType.PrettyPrint()} is not a {typeof(ISnapshot).PrettyPrint()}"); } @@ -221,7 +222,11 @@ private void RegisterDefaults(IServiceRegistration serviceRegistration) serviceRegistration.Register(); serviceRegistration.Register(); serviceRegistration.Register(); +#if NET451 serviceRegistration.Register(Lifetime.Singleton); +#else + serviceRegistration.Register(Lifetime.Singleton); +#endif serviceRegistration.RegisterGeneric(typeof(ISagaUpdater<,,,>), typeof(SagaUpdater<,,,>)); serviceRegistration.Register(_ => _eventFlowConfiguration); serviceRegistration.RegisterGeneric(typeof(ITransientFaultHandler<>), typeof(TransientFaultHandler<>)); diff --git a/Source/EventFlow/EventStores/DomainEventFactory.cs b/Source/EventFlow/EventStores/DomainEventFactory.cs index 0947ee9ea..3c1f06438 100644 --- a/Source/EventFlow/EventStores/DomainEventFactory.cs +++ b/Source/EventFlow/EventStores/DomainEventFactory.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Concurrent; using System.Linq; +using System.Reflection; using EventFlow.Aggregates; using EventFlow.Core; using EventFlow.Extensions; @@ -87,30 +88,32 @@ public IDomainEvent Upgrade( private static Type GetIdentityType(Type domainEventType) { var domainEventInterfaceType = domainEventType + .GetTypeInfo() .GetInterfaces() - .SingleOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDomainEvent<,>)); + .SingleOrDefault(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IDomainEvent<,>)); if (domainEventInterfaceType == null) { throw new ArgumentException($"Type '{domainEventType.PrettyPrint()}' is not a '{typeof(IDomainEvent<,>).PrettyPrint()}'"); } - var genericArguments = domainEventInterfaceType.GetGenericArguments(); + var genericArguments = domainEventInterfaceType.GetTypeInfo().GetGenericArguments(); return genericArguments[1]; } private static Type GetDomainEventType(Type aggregateEventType) { var aggregateEventInterfaceType = aggregateEventType + .GetTypeInfo() .GetInterfaces() - .SingleOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateEvent<,>)); + .SingleOrDefault(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateEvent<,>)); if (aggregateEventInterfaceType == null) { throw new ArgumentException($"Type '{aggregateEventType.PrettyPrint()}' is not a '{typeof(IAggregateEvent<,>).PrettyPrint()}'"); } - var genericArguments = aggregateEventInterfaceType.GetGenericArguments(); + var genericArguments = aggregateEventInterfaceType.GetTypeInfo().GetGenericArguments(); return typeof(DomainEvent<,,>).MakeGenericType(genericArguments[0], genericArguments[1], aggregateEventType); } } diff --git a/Source/EventFlow/EventStores/EventUpgradeManager.cs b/Source/EventFlow/EventStores/EventUpgradeManager.cs index 383725a3c..a559ad8c8 100644 --- a/Source/EventFlow/EventStores/EventUpgradeManager.cs +++ b/Source/EventFlow/EventStores/EventUpgradeManager.cs @@ -25,6 +25,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; +using System.Reflection; using EventFlow.Aggregates; using EventFlow.Configuration; using EventFlow.Core; @@ -121,13 +122,13 @@ private static EventUpgraderCacheItem GetCache(Type aggregateType) aggregateType, t => { - var aggregateRootInterface = t.GetInterfaces().SingleOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateRoot<>)); + var aggregateRootInterface = t.GetTypeInfo().GetInterfaces().SingleOrDefault(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateRoot<>)); if (aggregateRootInterface == null) { throw new ArgumentException($"Type '{t.PrettyPrint()}' is not a '{typeof(IAggregateRoot<>).PrettyPrint()}'", nameof(aggregateType)); } - var arguments = aggregateRootInterface.GetGenericArguments(); + var arguments = aggregateRootInterface.GetTypeInfo().GetGenericArguments(); var eventUpgraderType = typeof(IEventUpgrader<,>).MakeGenericType(t, arguments[0]); var invokeUpgrade = ReflectionHelper.CompileMethodInvocation>>(eventUpgraderType, "Upgrade"); diff --git a/Source/EventFlow/Extensions/EventFlowOptionsCommandExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsCommandExtensions.cs index a9f861339..d2b79be2c 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsCommandExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsCommandExtensions.cs @@ -45,7 +45,7 @@ public static IEventFlowOptions AddCommands( predicate = predicate ?? (t => true); var commandTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(ICommand).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(ICommand).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddCommands(commandTypes); } diff --git a/Source/EventFlow/Extensions/EventFlowOptionsCommandHandlerExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsCommandHandlerExtensions.cs index 77b607c19..d6a4dd566 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsCommandHandlerExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsCommandHandlerExtensions.cs @@ -39,7 +39,7 @@ public static IEventFlowOptions AddCommandHandlers( predicate = predicate ?? (t => true); var commandHandlerTypes = fromAssembly .GetTypes() - .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommandHandler<,,,>))) + .Where(t => t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommandHandler<,,,>))) .Where(t => predicate(t)); return eventFlowOptions.AddCommandHandlers(commandHandlerTypes); } @@ -58,10 +58,11 @@ public static IEventFlowOptions AddCommandHandlers( foreach (var commandHandlerType in commandHandlerTypes) { var t = commandHandlerType; - if (t.IsAbstract) continue; + if (t.GetTypeInfo().IsAbstract) continue; var handlesCommandTypes = t + .GetTypeInfo() .GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommandHandler<,,,>)) + .Where(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ICommandHandler<,,,>)) .ToList(); if (!handlesCommandTypes.Any()) { diff --git a/Source/EventFlow/Extensions/EventFlowOptionsEventUpgradersExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsEventUpgradersExtensions.cs index a723324fb..c4440d49a 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsEventUpgradersExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsEventUpgradersExtensions.cs @@ -60,7 +60,7 @@ public static IEventFlowOptions AddEventUpgraders( predicate = predicate ?? (t => true); var eventUpgraderTypes = fromAssembly .GetTypes() - .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEventUpgrader<,>))) + .Where(t => t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IEventUpgrader<,>))) .Where(t => predicate(t)); return eventFlowOptions .AddEventUpgraders(eventUpgraderTypes); @@ -81,10 +81,11 @@ public static IEventFlowOptions AddEventUpgraders( foreach (var eventUpgraderType in eventUpgraderTypes) { var t = eventUpgraderType; - if (t.IsAbstract) continue; + if (t.GetTypeInfo().IsAbstract) continue; var eventUpgraderForAggregateType = t + .GetTypeInfo() .GetInterfaces() - .SingleOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IEventUpgrader<,>)); + .SingleOrDefault(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IEventUpgrader<,>)); if (eventUpgraderForAggregateType == null) { throw new ArgumentException($"Type '{eventUpgraderType.Name}' does not have the '{typeof(IEventUpgrader<,>).PrettyPrint()}' interface"); diff --git a/Source/EventFlow/Extensions/EventFlowOptionsEventsExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsEventsExtensions.cs index dbc88340c..b757a731d 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsEventsExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsEventsExtensions.cs @@ -39,7 +39,7 @@ public static IEventFlowOptions AddEvents( predicate = predicate ?? (t => true); var aggregateEventTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(IAggregateEvent).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(IAggregateEvent).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddEvents(aggregateEventTypes); } diff --git a/Source/EventFlow/Extensions/EventFlowOptionsJobExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsJobExtensions.cs index 5c602e875..3a7eaf76a 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsJobExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsJobExtensions.cs @@ -45,7 +45,7 @@ public static IEventFlowOptions AddJobs( predicate = predicate ?? (t => true); var jobTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(IJob).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(IJob).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddJobs(jobTypes); } diff --git a/Source/EventFlow/Extensions/EventFlowOptionsMetadataProvidersExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsMetadataProvidersExtensions.cs index c322dc916..277eea088 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsMetadataProvidersExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsMetadataProvidersExtensions.cs @@ -57,7 +57,7 @@ public static IEventFlowOptions AddMetadataProviders( predicate = predicate ?? (t => true); var metadataProviderTypes = fromAssembly .GetTypes() - .Where(t => typeof(IMetadataProvider).IsAssignableFrom(t)) + .Where(t => typeof(IMetadataProvider).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddMetadataProviders(metadataProviderTypes); } @@ -69,8 +69,8 @@ public static IEventFlowOptions AddMetadataProviders( foreach (var metadataProviderType in metadataProviderTypes) { var t = metadataProviderType; - if (t.IsAbstract) continue; - if (!typeof(IMetadataProvider).IsAssignableFrom(t)) + if (t.GetTypeInfo().IsAbstract) continue; + if (!typeof(IMetadataProvider).GetTypeInfo().IsAssignableFrom(t)) { throw new ArgumentException($"Type '{metadataProviderType.PrettyPrint()}' is not an '{typeof(IMetadataProvider).PrettyPrint()}'"); } diff --git a/Source/EventFlow/Extensions/EventFlowOptionsQueriesExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsQueriesExtensions.cs index 98ab65c59..79230e9fa 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsQueriesExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsQueriesExtensions.cs @@ -54,7 +54,7 @@ public static IEventFlowOptions AddQueryHandlers( predicate = predicate ?? (t => true); var subscribeSynchronousToTypes = fromAssembly .GetTypes() - .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>))) + .Where(t => t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>))) .Where(t => predicate(t)); return eventFlowOptions .AddQueryHandlers(subscribeSynchronousToTypes); @@ -67,10 +67,11 @@ public static IEventFlowOptions AddQueryHandlers( foreach (var queryHandlerType in queryHandlerTypes) { var t = queryHandlerType; - if (t.IsAbstract) continue; + if (t.GetTypeInfo().IsAbstract) continue; var queryHandlerInterfaces = t + .GetTypeInfo() .GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>)) + .Where(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IQueryHandler<,>)) .ToList(); if (!queryHandlerInterfaces.Any()) { diff --git a/Source/EventFlow/Extensions/EventFlowOptionsSagasExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsSagasExtensions.cs index 9366ff0b8..d9a903769 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsSagasExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsSagasExtensions.cs @@ -39,7 +39,7 @@ public static IEventFlowOptions AddSagas( predicate = predicate ?? (t => true); var sagaTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(ISaga).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(ISaga).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddSagas(sagaTypes); @@ -60,7 +60,7 @@ public static IEventFlowOptions AddSagaLocators( predicate = predicate ?? (t => true); var sagaTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(ISagaLocator).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(ISagaLocator).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddSagaLocators(sagaTypes); @@ -81,7 +81,7 @@ public static IEventFlowOptions AddSagaLocators( { foreach (var sagaLocatorType in sagaLocatorTypes) { - if (!typeof(ISagaLocator).IsAssignableFrom(sagaLocatorType)) + if (!typeof(ISagaLocator).GetTypeInfo().IsAssignableFrom(sagaLocatorType)) { throw new ArgumentException($"Type '{sagaLocatorType.PrettyPrint()}' is not a '{typeof(ISagaLocator).PrettyPrint()}'"); } diff --git a/Source/EventFlow/Extensions/EventFlowOptionsSnapshotExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsSnapshotExtensions.cs index b3e7bc382..710bd86aa 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsSnapshotExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsSnapshotExtensions.cs @@ -49,7 +49,7 @@ public static IEventFlowOptions AddSnapshots( predicate = predicate ?? (t => true); var snapshotTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract && typeof(ISnapshot).IsAssignableFrom(t)) + .Where(t => !t.GetTypeInfo().IsAbstract && typeof(ISnapshot).GetTypeInfo().IsAssignableFrom(t)) .Where(t => predicate(t)); return eventFlowOptions.AddSnapshots(snapshotTypes); } @@ -63,8 +63,8 @@ public static IEventFlowOptions AddSnapshotUpgraders( var snapshotUpgraderTypes = fromAssembly .GetTypes() - .Where(t => !t.IsAbstract) - .Where(t => t.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISnapshotUpgrader<,>))) + .Where(t => !t.GetTypeInfo().IsAbstract) + .Where(t => t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ISnapshotUpgrader<,>))) .Where(t => predicate(t)); return eventFlowOptions.AddSnapshotUpgraders(snapshotUpgraderTypes); @@ -86,8 +86,9 @@ public static IEventFlowOptions AddSnapshotUpgraders( foreach (var snapshotUpgraderType in snapshotUpgraderTypes) { var interfaceType = snapshotUpgraderType + .GetTypeInfo() .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISnapshotUpgrader<,>)); + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ISnapshotUpgrader<,>)); sr.Register(interfaceType, snapshotUpgraderType); } }); diff --git a/Source/EventFlow/Extensions/EventFlowOptionsSubscriberExtensions.cs b/Source/EventFlow/Extensions/EventFlowOptionsSubscriberExtensions.cs index 75b0dbc19..73f0f0072 100644 --- a/Source/EventFlow/Extensions/EventFlowOptionsSubscriberExtensions.cs +++ b/Source/EventFlow/Extensions/EventFlowOptionsSubscriberExtensions.cs @@ -60,9 +60,10 @@ public static IEventFlowOptions AddSubscribers( var subscribeSynchronousToTypes = fromAssembly .GetTypes() .Where(t => t + .GetTypeInfo() .GetInterfaces() .Any(i => - (i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISubscribeSynchronousTo<,,>)) || + (i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ISubscribeSynchronousTo<,,>)) || i == typeof(ISubscribeSynchronousToAll))) .Where(t => predicate(t)); return eventFlowOptions.AddSubscribers(subscribeSynchronousToTypes); @@ -75,11 +76,12 @@ public static IEventFlowOptions AddSubscribers( foreach (var subscribeSynchronousToType in subscribeSynchronousToTypes) { var t = subscribeSynchronousToType; - if (t.IsAbstract) continue; + if (t.GetTypeInfo().IsAbstract) continue; var subscribeTos = t + .GetTypeInfo() .GetInterfaces() .Where(i => - (i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISubscribeSynchronousTo<,,>)) || + i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(ISubscribeSynchronousTo<,,>) || i == typeof(ISubscribeSynchronousToAll)) .ToList(); if (!subscribeTos.Any()) diff --git a/Source/EventFlow/Extensions/StringExtensions.cs b/Source/EventFlow/Extensions/StringExtensions.cs index 7aa551e05..c261fbc29 100644 --- a/Source/EventFlow/Extensions/StringExtensions.cs +++ b/Source/EventFlow/Extensions/StringExtensions.cs @@ -31,7 +31,7 @@ namespace EventFlow.Extensions public static class StringExtensions { private static readonly Regex RegexToSlug = new Regex("(?<=.)([A-Z])", RegexOptions.Compiled); - private static readonly SHA256Managed Sha256Managed = new SHA256Managed(); + private static readonly SHA256 Sha256Managed = SHA256.Create(); public static string ToSlug(this string str) { diff --git a/Source/EventFlow/Extensions/TypeExtensions.cs b/Source/EventFlow/Extensions/TypeExtensions.cs index cae32fd85..b916b45fb 100644 --- a/Source/EventFlow/Extensions/TypeExtensions.cs +++ b/Source/EventFlow/Extensions/TypeExtensions.cs @@ -73,7 +73,7 @@ private static string PrettyPrintRecursive(Type type, int depth) return nameParts[0]; } - var genericArguments = type.GetGenericArguments(); + var genericArguments = type.GetTypeInfo().GetGenericArguments(); return !type.IsConstructedGenericType ? $"{nameParts[0]}<{new string(',', genericArguments.Length - 1)}>" : $"{nameParts[0]}<{string.Join(",", genericArguments.Select(t => PrettyPrintRecursive(t, depth + 1)))}>"; @@ -88,13 +88,13 @@ public static AggregateName GetAggregateName( aggregateType, t => { - if (!typeof(IAggregateRoot).IsAssignableFrom(aggregateType)) + if (!typeof(IAggregateRoot).GetTypeInfo().IsAssignableFrom(aggregateType)) { throw new ArgumentException($"Type '{aggregateType.PrettyPrint()}' is not an aggregate root"); } return new AggregateName( - t.GetCustomAttributes().SingleOrDefault()?.Name ?? + t.GetTypeInfo().GetCustomAttributes().SingleOrDefault()?.Name ?? t.Name); }); } @@ -114,7 +114,7 @@ internal static IReadOnlyDictionary> GetAggrega var parameters = mi.GetParameters(); return parameters.Length == 1 && - aggregateEventType.IsAssignableFrom(parameters[0].ParameterType); + aggregateEventType.GetTypeInfo().IsAssignableFrom(parameters[0].ParameterType); }) .ToDictionary( mi => mi.GetParameters()[0].ParameterType, diff --git a/Source/EventFlow/MetadataProviders/AddEventTypeMetadataProvider.cs b/Source/EventFlow/MetadataProviders/AddEventTypeMetadataProvider.cs index 1cc60f7e7..38ef201da 100644 --- a/Source/EventFlow/MetadataProviders/AddEventTypeMetadataProvider.cs +++ b/Source/EventFlow/MetadataProviders/AddEventTypeMetadataProvider.cs @@ -22,6 +22,7 @@ // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using System.Collections.Generic; +using System.Reflection; using EventFlow.Aggregates; using EventFlow.Core; using EventFlow.EventStores; @@ -38,7 +39,7 @@ public IEnumerable> ProvideMetadata("event_type_assembly_version", name.Version.ToString()); diff --git a/Source/EventFlow/Queries/QueryProcessor.cs b/Source/EventFlow/Queries/QueryProcessor.cs index 8a9b03070..bc02cbd8e 100644 --- a/Source/EventFlow/Queries/QueryProcessor.cs +++ b/Source/EventFlow/Queries/QueryProcessor.cs @@ -23,6 +23,7 @@ using System; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Configuration; @@ -92,9 +93,10 @@ private Task GetCacheItemAsync( _ => { var queryInterfaceType = queryType + .GetTypeInfo() .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IQuery<>)); - var queryHandlerType = typeof(IQueryHandler<,>).MakeGenericType(queryType, queryInterfaceType.GetGenericArguments()[0]); + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IQuery<>)); + var queryHandlerType = typeof(IQueryHandler<,>).MakeGenericType(queryType, queryInterfaceType.GetTypeInfo().GetGenericArguments()[0]); var invokeExecuteQueryAsync = ReflectionHelper.CompileMethodInvocation>( queryHandlerType, "ExecuteQueryAsync", diff --git a/Source/EventFlow/ReadStores/ReadModelDomainEventApplier.cs b/Source/EventFlow/ReadStores/ReadModelDomainEventApplier.cs index c630f849f..25c4b9169 100644 --- a/Source/EventFlow/ReadStores/ReadModelDomainEventApplier.cs +++ b/Source/EventFlow/ReadStores/ReadModelDomainEventApplier.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; @@ -57,7 +58,7 @@ public Task UpdateReadModelAsync( var domainEventType = typeof(IDomainEvent<,,>).MakeGenericType(domainEvent.AggregateType, domainEvent.GetIdentity().GetType(), t); var methodSignature = new[] {typeof(IReadModelContext), domainEventType}; - var methodInfo = readModelType.GetMethod("Apply", methodSignature); + var methodInfo = readModelType.GetTypeInfo().GetMethod("Apply", methodSignature); return methodInfo == null ? null diff --git a/Source/EventFlow/ReadStores/ReadModelPopulator.cs b/Source/EventFlow/ReadStores/ReadModelPopulator.cs index f646e8425..6a0f811b5 100644 --- a/Source/EventFlow/ReadStores/ReadModelPopulator.cs +++ b/Source/EventFlow/ReadStores/ReadModelPopulator.cs @@ -25,6 +25,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Configuration; @@ -85,9 +86,10 @@ public async Task PopulateAsync( var readStoreManagers = ResolveReadStoreManager(); var aggregateEventTypes = new HashSet(readModelType + .GetTypeInfo() .GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAmReadModelFor<,,>)) - .Select(i => i.GetGenericArguments()[2])); + .Where(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IAmReadModelFor<,,>)) + .Select(i => i.GetTypeInfo().GetGenericArguments()[2])); _log.Verbose(() => string.Format( "Read model '{0}' is interested in these aggregate events: {1}", diff --git a/Source/EventFlow/ReadStores/ReadStoreManager.cs b/Source/EventFlow/ReadStores/ReadStoreManager.cs index e23c5c118..24879f551 100644 --- a/Source/EventFlow/ReadStores/ReadStoreManager.cs +++ b/Source/EventFlow/ReadStores/ReadStoreManager.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; @@ -55,8 +56,9 @@ public abstract class ReadStoreManager : IReadStore static ReadStoreManager() { var iAmReadModelForInterfaceTypes = ReadModelType + .GetTypeInfo() .GetInterfaces() - .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAmReadModelFor<,,>)) + .Where(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IAmReadModelFor<,,>)) .ToList(); if (!iAmReadModelForInterfaceTypes.Any()) { @@ -64,8 +66,8 @@ static ReadStoreManager() $"Read model type '{ReadModelType.PrettyPrint()}' does not implement any '{typeof(IAmReadModelFor<,,>).PrettyPrint()}'"); } - AggregateTypes = new HashSet(iAmReadModelForInterfaceTypes.Select(i => i.GetGenericArguments()[0])); - AggregateEventTypes = new HashSet(iAmReadModelForInterfaceTypes.Select(i => i.GetGenericArguments()[2])); + AggregateTypes = new HashSet(iAmReadModelForInterfaceTypes.Select(i => i.GetTypeInfo().GetGenericArguments()[0])); + AggregateEventTypes = new HashSet(iAmReadModelForInterfaceTypes.Select(i => i.GetTypeInfo().GetGenericArguments()[2])); } protected ReadStoreManager( diff --git a/Source/EventFlow/Sagas/AggregateSagas/SagaAggregateStore.cs b/Source/EventFlow/Sagas/AggregateSagas/SagaAggregateStore.cs index a152ee7ed..328814187 100644 --- a/Source/EventFlow/Sagas/AggregateSagas/SagaAggregateStore.cs +++ b/Source/EventFlow/Sagas/AggregateSagas/SagaAggregateStore.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; @@ -88,14 +89,15 @@ private async Task _ => { var aggregateRootType = sagaType + .GetTypeInfo() .GetInterfaces() - .FirstOrDefault(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateRoot<>)); + .FirstOrDefault(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IAggregateRoot<>)); if (aggregateRootType == null) throw new ArgumentException($"Saga '{sagaType.PrettyPrint()}' is not a aggregate root"); - var methodInfo = GetType().GetMethod(nameof(UpdateAggregateAsync)); - var identityType = aggregateRootType.GetGenericArguments()[0]; + var methodInfo = GetType().GetTypeInfo().GetMethod(nameof(UpdateAggregateAsync)); + var identityType = aggregateRootType.GetTypeInfo().GetGenericArguments()[0]; var genericMethodInfo = methodInfo.MakeGenericMethod(sagaType, identityType); return Task.FromResult, CancellationToken, Task>>>( (id, sid, u, c) => (Task>)genericMethodInfo.Invoke(this, new object[] { id, sid, u, c })); diff --git a/Source/EventFlow/Sagas/SagaDetails.cs b/Source/EventFlow/Sagas/SagaDetails.cs index a66f4c24e..f6b37184d 100644 --- a/Source/EventFlow/Sagas/SagaDetails.cs +++ b/Source/EventFlow/Sagas/SagaDetails.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using EventFlow.Extensions; namespace EventFlow.Sagas @@ -38,14 +39,18 @@ public static SagaDetails From() public static SagaDetails From(Type sagaType) { - if (!typeof(ISaga).IsAssignableFrom(sagaType)) + if (!typeof(ISaga).GetTypeInfo().IsAssignableFrom(sagaType)) { throw new ArgumentException( $"Type {sagaType.PrettyPrint()} is not a {typeof(ISaga).PrettyPrint()}", nameof(sagaType)); } - var sagaInterfaces = sagaType.GetInterfaces(); + var sagaInterfaces = sagaType + .GetTypeInfo() + .GetInterfaces() + .Select(i => i.GetTypeInfo()) + .ToList(); var sagaHandlesTypes = sagaInterfaces .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ISagaHandles<,,>)) .ToList(); diff --git a/Source/EventFlow/Subscribers/DispatchToEventSubscribers.cs b/Source/EventFlow/Subscribers/DispatchToEventSubscribers.cs index c430f4aac..54c835449 100644 --- a/Source/EventFlow/Subscribers/DispatchToEventSubscribers.cs +++ b/Source/EventFlow/Subscribers/DispatchToEventSubscribers.cs @@ -24,6 +24,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using EventFlow.Aggregates; @@ -142,8 +143,10 @@ private Task GetSubscriberInfomationAsync( _ => { var arguments = domainEventType + .GetTypeInfo() .GetInterfaces() - .Single(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IDomainEvent<,,>)) + .Single(i => i.GetTypeInfo().IsGenericType && i.GetGenericTypeDefinition() == typeof(IDomainEvent<,,>)) + .GetTypeInfo() .GetGenericArguments(); var handlerType = subscriberType.MakeGenericType(arguments[0], arguments[1], arguments[2]); diff --git a/Source/EventFlow/ValueObjects/SingleValueObjectConverter.cs b/Source/EventFlow/ValueObjects/SingleValueObjectConverter.cs index 249925c62..9c3529dcc 100644 --- a/Source/EventFlow/ValueObjects/SingleValueObjectConverter.cs +++ b/Source/EventFlow/ValueObjects/SingleValueObjectConverter.cs @@ -49,7 +49,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist objectType, t => { - var constructorInfo = objectType.GetConstructors(BindingFlags.Public | BindingFlags.Instance).Single(); + var constructorInfo = objectType.GetTypeInfo().GetConstructors(BindingFlags.Public | BindingFlags.Instance).Single(); var parameterInfo = constructorInfo.GetParameters().Single(); return parameterInfo.ParameterType; }); @@ -60,7 +60,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist public override bool CanConvert(Type objectType) { - return typeof(ISingleValueObject).IsAssignableFrom(objectType); + return typeof(ISingleValueObject).GetTypeInfo().IsAssignableFrom(objectType); } } } \ No newline at end of file diff --git a/Source/EventFlow/ValueObjects/ValueObject.cs b/Source/EventFlow/ValueObjects/ValueObject.cs index 22c66ba28..a874b00c1 100644 --- a/Source/EventFlow/ValueObjects/ValueObject.cs +++ b/Source/EventFlow/ValueObjects/ValueObject.cs @@ -75,6 +75,7 @@ protected virtual IEnumerable GetProperties() return TypeProperties.GetOrAdd( GetType(), t => t + .GetTypeInfo() .GetProperties(BindingFlags.Instance | BindingFlags.Public) .OrderBy(p => p.Name) .ToList()); diff --git a/appveyor.yml b/appveyor.yml index c8331003c..7bd302e43 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ init: - git config --global core.autocrlf input -version: 0.43.{build} +version: 0.44.{build} install: - cmd: pip install -U Sphinx