Skip to content

Commit f17bd30

Browse files
committed
TypeReflectionProvider ignores abstract IComponents #88
1 parent 18bad80 commit f17bd30

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

Entitas/Entitas/CodeGenerator/Providers/TypeReflectionProvider.cs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public TypeReflectionProvider(Type[] types, string[] poolNames) {
2020
public static ComponentInfo[] GetComponentInfos(Type[] types) {
2121
return types
2222
.Where(type => !type.IsInterface)
23+
.Where(type => !type.IsAbstract)
2324
.Where(type => type.GetInterfaces().Any(i => i.FullName == "Entitas.IComponent"))
2425
.Select(type => CreateComponentInfo(type))
2526
.ToArray();

Tests/Tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@
274274
<Link>Linked Libraries\Unity\VisualDebugging\DebugSystems\Feature.cs</Link>
275275
</Compile>
276276
<Compile Include="Tests\Entitas\Fixtures\Systems\GroupObserverSubSystemSpy.cs" />
277+
<Compile Include="Tests\Entitas\CodeGenerator\Fixtures\Components\AbstractComponent.cs" />
277278
</ItemGroup>
278279
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
279280
<ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
using Entitas;
2+
3+
public abstract class AbstractComponent : IComponent {
4+
}
5+

Tests/Tests/Entitas/CodeGenerator/Providers/describe_TypeReflectionProvider.cs

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ void when_providing() {
4040
provider.componentInfos.should_be_empty();
4141
};
4242

43+
it["finds no components and ignores abstract classes"] = () => {
44+
var provider = new TypeReflectionProvider(new [] { typeof(AbstractComponent) }, new string[0]);
45+
provider.componentInfos.should_be_empty();
46+
};
47+
4348
it["creates component info from found component"] = () => {
4449
var provider = new TypeReflectionProvider(new [] { typeof(ComponentA) }, new string[0]);
4550
provider.componentInfos.Length.should_be(1);

0 commit comments

Comments
 (0)