Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mef attacher creation #2093

Merged
merged 8 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- Build on and target .Net 9 rather than 8
- Fix issue with MEF constructing Remote Table Attachers

## [8.4.1] - 2024-12-10

Expand Down
32 changes: 32 additions & 0 deletions Rdmp.Core.Tests/DataLoad/Modules/Attachers/AttacherMEFTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using NPOI.SS.Formula.Functions;
using NUnit.Framework;
using Rdmp.Core.DataLoad.Engine.Attachers;
using Rdmp.Core.DataLoad.Modules.Attachers;
using Rdmp.Core.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tests.Common;

namespace Rdmp.Core.Tests.DataLoad.Modules.Attachers
{
public class AttacherMEFTest: UnitTests
{

[Test]
public void AttacherMEFCreationTest()
{
var types = MEF.GetTypes<IAttacher>().Where(t => !typeof(RemoteAttacher).IsAssignableTo(t)).ToArray();
List<string> AttacherPaths = types.Select(t => t.FullName).ToList();
foreach (var path in AttacherPaths)
{
Assert.DoesNotThrow(() =>
{
MEF.CreateA<IAttacher>(path);
});
}
}
}
}
5 changes: 5 additions & 0 deletions Rdmp.Core/DataLoad/Engine/Attachers/Attacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ protected Attacher(bool requestsExternalDatabaseCreation)
RequestsExternalDatabaseCreation = requestsExternalDatabaseCreation;
}

protected Attacher()
{
RequestsExternalDatabaseCreation = true;
}

public abstract void Check(ICheckNotifier notifier);


Expand Down
3 changes: 2 additions & 1 deletion Rdmp.Core/DataLoad/Modules/Attachers/RemoteAttacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ namespace Rdmp.Core.DataLoad.Modules.Attachers;
public class RemoteAttacher : Attacher, IPluginAttacher
{

public RemoteAttacher(bool requestsExternalDatabaseCreation=true) : base(requestsExternalDatabaseCreation) { }
public RemoteAttacher(bool requestsExternalDatabaseCreation = true) : base(requestsExternalDatabaseCreation) { }
public RemoteAttacher() : base(true) { }
[DemandsInitialization("How far back to pull data from")]
public AttacherHistoricalDurations HistoricalFetchDuration { get; set; }

Expand Down
3 changes: 3 additions & 0 deletions Rdmp.Core/DataLoad/Modules/Attachers/RemoteTableAttacher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class RemoteTableAttacher : RemoteAttacher
public RemoteTableAttacher(bool requestsExternalDatabaseCreation=true) : base(requestsExternalDatabaseCreation)
{
}
public RemoteTableAttacher() : base(true)
{
}

[DemandsInitialization(
"The server to connect to (this replaces all other settings e.g. RemoteServer, RemoteDatabaseName etc")]
Expand Down
Loading