Skip to content

Commit

Permalink
Merge pull request #421 from domenkogler/develop
Browse files Browse the repository at this point in the history
ReflectionHelper.CompileMethodInvocation
  • Loading branch information
rasmus committed Jan 25, 2018
2 parents 5e568ca + f1f5800 commit 1f44061
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
### New in 0.53 (not released yet)

* New: Allow events to have multiple `EventVersion` attributes
* Fixed: `ReflectionHelper.CompileMethodInvocation` now recognises
`private` methods.

### New in 0.52.3178 (released 2017-11-02)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ public int Add(int a, int b)
return a + b;
}

public Number Add(Number a, Number b)
private Number Add(Number a, Number b)
{
return new Number {I = Add(a.I, b.I)};
}

public Number Add(Number a, int b)
private Number Add(Number a, int b)
{
return new Number { I = Add(a.I, b) };
}
Expand Down
7 changes: 5 additions & 2 deletions Source/EventFlow/Core/ReflectionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,13 @@ public static string GetCodeBase(Assembly assembly, bool includeFileName = false
public static TResult CompileMethodInvocation<TResult>(Type type, string methodName, params Type[] methodSignature)
{
var typeInfo = type.GetTypeInfo();
var methods = typeInfo
.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(m => m.Name == methodName);

var methodInfo = methodSignature == null || !methodSignature.Any()
? typeInfo.GetMethods(BindingFlags.Instance | BindingFlags.Public).SingleOrDefault(m => m.Name == methodName)
: typeInfo.GetMethod(methodName, methodSignature);
? methods.SingleOrDefault()
: methods.SingleOrDefault(m => m.GetParameters().Select(mp => mp.ParameterType).SequenceEqual(methodSignature));

if (methodInfo == null)
{
Expand Down

0 comments on commit 1f44061

Please sign in to comment.