Skip to content

Commit

Permalink
close akkadotnet#4901 - replace reflection magic in MNTR with reading…
Browse files Browse the repository at this point in the history
… of MultiNodeConfig properties
  • Loading branch information
Aaronontheweb committed Apr 6, 2021
1 parent 4091508 commit 156f9f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/core/Akka.MultiNodeTestRunner/Discovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,8 @@ private IEnumerable<RoleName> RoleNames(Type specType)
var ctorWithConfig = FindConfigConstructor(specType);
var configType = ctorWithConfig.GetParameters().First().ParameterType;
var args = ConfigConstructorParamValues(configType);
var configInstance = Activator.CreateInstance(configType, args);
var roleType = typeof(RoleName);
var configProps = configType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
var roleProps = configProps.Where(p => p.PropertyType == roleType && p.Name != "Myself").Select(p => (RoleName)p.GetValue(configInstance));
var configFields = configType.GetFields(BindingFlags.Instance | BindingFlags.Public);
var roleFields = configFields.Where(f => f.FieldType == roleType && f.Name != "Myself").Select(f => (RoleName)f.GetValue(configInstance));
var roles = roleProps.Concat(roleFields).Distinct();
return roles;
var configInstance = (MultiNodeConfig)Activator.CreateInstance(configType, args);
return configInstance.Roles;
}

internal static ConstructorInfo FindConfigConstructor(Type configUser)
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote.TestKit/MultiNodeSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ internal ImmutableList<string> Deployments(RoleName node)
return deployments == null ? _allDeploy : deployments.AddRange(_allDeploy);
}

internal ImmutableList<RoleName> Roles
public ImmutableList<RoleName> Roles
{
get { return _roles; }
}
Expand Down

0 comments on commit 156f9f5

Please sign in to comment.