Skip to content

Commit

Permalink
fix: skip abstract classes when registering via AddWorksFromAssembly
Browse files Browse the repository at this point in the history
  • Loading branch information
alexalok committed Mar 2, 2023
1 parent 8e9e33a commit 325fac0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
9 changes: 9 additions & 0 deletions dotWork.Tests/WorkStubs/Work_Abstract.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Threading.Tasks;

namespace dotWork.Tests.WorkStubs
{
public abstract class Work_Abstract<TWorkOptions> : WorkBase<TWorkOptions>
where TWorkOptions: class, IWorkOptions
{
}
}
6 changes: 6 additions & 0 deletions dotWork.lutconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<LUTConfig Version="1.0">
<Repository />
<ParallelBuilds>true</ParallelBuilds>
<ParallelTestRuns>true</ParallelTestRuns>
<TestCaseTimeout>180000</TestCaseTimeout>
</LUTConfig>
5 changes: 4 additions & 1 deletion dotWork/Extensions/ContainerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ public static IServiceCollection AddWorksFromAssembly(
if (configuration is null)
throw new ArgumentNullException(nameof(configuration));

var workTypes = assembly.GetTypes().Where(t => t.ImplementsInterface(typeof(IWork<>)));
var workTypes = assembly.GetTypes().Where(t =>
t.ImplementsInterface(typeof(IWork<>))
&& !t.IsAbstract
);
foreach (var workType in workTypes)
{
if (typeSelector?.Invoke(workType) == false)
Expand Down
6 changes: 3 additions & 3 deletions dotWork/dotWork.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<PropertyGroup>
<Authors>alexalok</Authors>
<Description>.NET Workers made easy</Description>
<Copyright>Copyright © alexalok 2021</Copyright>
<Version>1.5.0</Version>
<Copyright>Copyright © alexalok 2021-2023</Copyright>
<Version>1.5.1</Version>
<PackageReleaseNotes>
* Introduced WorkHost.OnWorkStopped and IWork.OnIterationException events.
* fix: skip abstract classes when registering via AddWorksFromAssembly
</PackageReleaseNotes>
<PackageProjectUrl></PackageProjectUrl>
<RepositoryUrl>https://github.com/alexalok/dotWork</RepositoryUrl>
Expand Down

0 comments on commit 325fac0

Please sign in to comment.