Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmus committed May 12, 2017
2 parents ed3e5e5 + f8629d1 commit fff9097
Show file tree
Hide file tree
Showing 50 changed files with 156 additions and 96 deletions.
13 changes: 12 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/EventFlow.Autofac/EventFlow.Autofac.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ReadModelDescription GetReadModelDescription<TReadModel>() where TReadMod
typeof(TReadModel),
t =>
{
var elasticType = t.GetCustomAttribute<ElasticsearchTypeAttribute>();
var elasticType = t.GetTypeInfo().GetCustomAttribute<ElasticsearchTypeAttribute>();
var indexName = elasticType == null
? $"eventflow-{typeof(TReadModel).PrettyPrint().ToLowerInvariant()}"
: elasticType.Name;
Expand Down
2 changes: 1 addition & 1 deletion Source/EventFlow.Hangfire/EventFlow.Hangfire.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand Down
1 change: 1 addition & 0 deletions Source/EventFlow.Owin.Tests/EventFlow.Owin.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ItemGroup>
<PackageReference Include="Autofac.WebApi2.Owin" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNet.WebApi.Core" Version="5.2.3" />
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Hosting" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion Source/EventFlow.Owin/EventFlow.Owin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Owin" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\EventFlow\EventFlow.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion Source/EventFlow.RabbitMQ/EventFlow.RabbitMQ.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using EventFlow.Core;
Expand Down Expand Up @@ -73,7 +74,7 @@ private async Task<ConnectionFactory> CreateConnectionFactoryAsync(Uri uri, Canc
AutomaticRecoveryEnabled = true,
ClientProperties = new Dictionary<string, object>
{
{ "eventflow-version", typeof(RabbitMqConnectionFactory).Assembly.GetName().Version.ToString() },
{ "eventflow-version", typeof(RabbitMqConnectionFactory).GetTypeInfo().Assembly.GetName().Version.ToString() },
{ "machine-name", Environment.MachineName },
},
};
Expand Down
6 changes: 4 additions & 2 deletions Source/EventFlow/CommandBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -154,9 +155,10 @@ private Task<CommandExecutionDetails> 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);
Expand Down
2 changes: 2 additions & 0 deletions Source/EventFlow/Configuration/Decorators/DecoratorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace EventFlow.Configuration.Decorators
{
Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion Source/EventFlow/Core/Caching/MemoryCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,4 +90,6 @@ protected override Task<T> GetAsync<T>(
return Task.FromResult(value);
}
}
}
}

#endif
8 changes: 5 additions & 3 deletions Source/EventFlow/Core/GuidFactories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Source/EventFlow/Core/Identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static IEnumerable<string> 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}'";
Expand Down
7 changes: 3 additions & 4 deletions Source/EventFlow/Core/IoC/EventFlowIoCResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<>))
{
Expand Down Expand Up @@ -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);
Expand All @@ -107,7 +106,7 @@ public IEnumerable<object> ResolveAll(Type serviceType)
public IEnumerable<Type> GetRegisteredServices()
{
return _registrations.Keys
.Where(t => !t.IsGenericTypeDefinition);
.Where(t => !t.GetTypeInfo().IsGenericTypeDefinition);
}

public bool HasRegistrationFor<T>()
Expand Down
3 changes: 1 addition & 2 deletions Source/EventFlow/Core/IoC/Factories/ConstructorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Reflection;
using EventFlow.Configuration;
Expand All @@ -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();
Expand Down
5 changes: 2 additions & 3 deletions Source/EventFlow/Core/IoC/Factories/GenericFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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];
Expand Down
3 changes: 2 additions & 1 deletion Source/EventFlow/Core/IoC/Registration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using EventFlow.Configuration;
using EventFlow.Configuration.Decorators;

Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion Source/EventFlow/Core/IoC/ServiceRegistration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using EventFlow.Configuration;

namespace EventFlow.Core.IoC
Expand All @@ -35,7 +36,7 @@ protected static IReadOnlyCollection<IBootstrap> OrderBootstraps(IEnumerable<IBo
.Select(b => new
{
Bootstrap = b,
AssemblyName = b.GetType().Assembly.GetName().Name,
AssemblyName = b.GetType().GetTypeInfo().Assembly.GetName().Name,
})
.ToList();
var eventFlowBootstraps = list
Expand Down
10 changes: 6 additions & 4 deletions Source/EventFlow/Core/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?
Expand All @@ -50,16 +50,18 @@ public static string GetCodeBase(Assembly assembly, bool includeFileName = false
/// </summary>
public static TResult CompileMethodInvocation<TResult>(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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System;
using System.Collections.Generic;
using System.Reflection;
using EventFlow.Extensions;
using EventFlow.ValueObjects;

Expand All @@ -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()})";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ public void Load(IReadOnlyCollection<Type> types)
}

var invalidTypes = types
.Where(t => !typeof(TTypeCheck)
.IsAssignableFrom(t))
.Where(t => !typeof(TTypeCheck).GetTypeInfo().IsAssignableFrom(t))
.ToList();
if (invalidTypes.Any())
{
Expand All @@ -88,7 +87,7 @@ public void Load(IReadOnlyCollection<Type> 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();
Expand Down Expand Up @@ -229,6 +228,7 @@ private TDefinition CreateDefinitionFromName(Type versionedType)
private TDefinition CreateDefinitionFromAttribute(Type versionedType)
{
var attribute = versionedType
.GetTypeInfo()
.GetCustomAttributes()
.OfType<TAttribute>()
.SingleOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

using System;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using EventFlow.Configuration;
Expand Down Expand Up @@ -96,7 +97,7 @@ private async Task<TVersionedType> 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 });

Expand Down
5 changes: 3 additions & 2 deletions Source/EventFlow/EventFlow.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../Common.props" />
<PropertyGroup>
<TargetFramework>net451</TargetFramework>
<TargetFrameworks>net451;netstandard1.6</TargetFrameworks>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<GenerateAssemblyInfo>True</GenerateAssemblyInfo>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
Expand All @@ -28,7 +28,8 @@
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net451'">
<Reference Include="System.Runtime.Caching" />
</ItemGroup>
</Project>
Loading

0 comments on commit fff9097

Please sign in to comment.