Skip to content

Commit 55ade26

Browse files
jas88JFrieldependabot[bot]
authored
Feature/rc4 (#1570)
* Syntax tidying * Dependency updates * Event handling singletons (ThrowImmediately and co) --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: James A Sutherland <> Co-authored-by: James Friel <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent d6edf73 commit 55ade26

File tree

1,430 files changed

+13535
-17853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,430 files changed

+13535
-17853
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ jobs:
5555
mysql-version: '8.0'
5656
root-password: 'YourStrong!Passw0rd'
5757
auto-start: true
58+
- name: Populate Databases.yaml
59+
shell: bash
60+
run: |
61+
find ./Tools/rdmp/Databases.yaml -type f -exec sed -i 's/RDMP_/TEST_/g' {} \;
5862
- name: Build
5963
run: dotnet build --configuration Release --verbosity minimal
6064
- name: Create MySql Logging, DQE and Cohort Building Cache Db
@@ -73,10 +77,10 @@ jobs:
7377
EOF
7478
- name: Run integration test scripts
7579
run: |
76-
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_list_destroy_catalogue.yaml &&
77-
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_cohort.yaml &&
78-
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_dataload.yaml &&
79-
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/orphan_extractable_column.yaml &&
80+
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_list_destroy_catalogue.yaml
81+
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_cohort.yaml
82+
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/create_dataload.yaml
83+
dotnet run -c Release --no-build --project Tools/rdmp/rdmp.csproj -- -f ./scripts/orphan_extractable_column.yaml
8084
- name: Test (DB)
8185
shell: bash
8286
run: |

Application/ResearchDataManagementPlatform/Menus/MenuItems/DataExportMenu.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) The University of Dundee 2018-2019
1+
// Copyright (c) The University of Dundee 2018-2023
22
// This file is part of the Research Data Management Platform (RDMP).
33
// RDMP is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
44
// RDMP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
@@ -12,7 +12,7 @@
1212

1313
namespace ResearchDataManagementPlatform.Menus.MenuItems;
1414

15-
internal class DataExportMenu : RDMPToolStripMenuItem
15+
internal sealed class DataExportMenu : RDMPToolStripMenuItem
1616
{
1717
public DataExportMenu(IActivateItems activator) : base(activator, "Data Export Options")
1818
{

Application/ResearchDataManagementPlatform/Menus/MenuItems/DisableTutorialsMenuItem.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ namespace ResearchDataManagementPlatform.Menus.MenuItems;
1515
/// Disables displaying Tutorials in RDMP
1616
/// </summary>
1717
[System.ComponentModel.DesignerCategory("")]
18-
public class DisableTutorialsMenuItem : ToolStripMenuItem
18+
public sealed class DisableTutorialsMenuItem : ToolStripMenuItem
1919
{
2020
private readonly TutorialTracker _tracker;
2121

2222
public DisableTutorialsMenuItem(ToolStripMenuItem parent, TutorialTracker tracker)
2323
{
24-
parent.DropDownOpened += parent_DropDownOpened;
24+
parent.DropDownOpened += Parent_DropDownOpened;
2525
_tracker = tracker;
2626
Text = "Disable Tutorials";
2727
}
2828

29-
private void parent_DropDownOpened(object sender, EventArgs e)
29+
private void Parent_DropDownOpened(object sender, EventArgs e)
3030
{
3131
Checked = UserSettings.DisableTutorials;
3232
}

Application/ResearchDataManagementPlatform/Menus/MenuItems/LaunchTutorialMenuItem.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,13 @@ namespace ResearchDataManagementPlatform.Menus.MenuItems;
1717
[System.ComponentModel.DesignerCategory("")]
1818
public class LaunchTutorialMenuItem : ToolStripMenuItem
1919
{
20-
private IActivateItems _activator;
2120
private readonly Tutorial _tutorial;
2221
private readonly TutorialTracker _tracker;
2322

2423
public LaunchTutorialMenuItem(ToolStripMenuItem parent, IActivateItems activator, Tutorial tutorial,
2524
TutorialTracker tracker)
2625
{
2726
parent.DropDownOpening += parent_DropDownOpening;
28-
_activator = activator;
2927
_tutorial = tutorial;
3028
_tracker = tracker;
3129

Application/ResearchDataManagementPlatform/Menus/MenuItems/ResetTutorialsMenuItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace ResearchDataManagementPlatform.Menus.MenuItems;
1414
/// Clears all user progress on Tutorials
1515
/// </summary>
1616
[System.ComponentModel.DesignerCategory("")]
17-
public class ResetTutorialsMenuItem : ToolStripMenuItem
17+
public sealed class ResetTutorialsMenuItem : ToolStripMenuItem
1818
{
1919
private readonly TutorialTracker _tracker;
2020

Application/ResearchDataManagementPlatform/Menus/RDMPTopMenuStripUI.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public RDMPTopMenuStripUI()
8282

8383
private void BuildSwitchInstanceMenuItems()
8484
{
85-
var args = RDMPBootStrapper<RDMPMainForm>.ApplicationArguments;
85+
var args = RDMPBootStrapper.ApplicationArguments;
8686

8787
// somehow app was launched without populating the load args
8888
if (args == null) return;
@@ -103,7 +103,7 @@ private void BuildSwitchInstanceMenuItems()
103103
AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, exeDir);
104104

105105
// also add yaml files from wherever they got their original yaml file
106-
if (origYamlFile?.FileLoaded != null && !exeDir.FullName.Equals(origYamlFile.FileLoaded.Directory.FullName))
106+
if (origYamlFile?.FileLoaded != null && !exeDir.FullName.Equals(origYamlFile.FileLoaded.Directory?.FullName))
107107
AddMenuItemsForSwitchingToInstancesInYamlFilesOf(origYamlFile, origYamlFile.FileLoaded.Directory);
108108
}
109109

@@ -120,14 +120,14 @@ private void AddMenuItemsForSwitchingToInstancesInYamlFilesOf(ConnectionStringsY
120120
yaml.FullName.Equals(origYamlFile.FileLoaded.FullName);
121121

122122
var launchNew = new ToolStripMenuItem(connectionStrings.Name ?? yaml.Name, null,
123-
(s, e) => { LaunchNew(connectionStrings); })
123+
(_, _) => { LaunchNew(connectionStrings); })
124124
{
125125
Checked = isSameAsCurrent,
126126
ToolTipText = connectionStrings.Description ?? yaml.FullName
127127
};
128128

129129
var switchTo = new ToolStripMenuItem(connectionStrings.Name ?? yaml.Name, null,
130-
(s, e) => { SwitchTo(connectionStrings); })
130+
(_, _) => { SwitchTo(connectionStrings); })
131131
{
132132
Enabled = !isSameAsCurrent,
133133
Checked = isSameAsCurrent,
@@ -244,7 +244,6 @@ private void generateClassTableSummaryToolStripMenuItem_Click(object sender, Eve
244244
report.GenerateReport(Activator.RepositoryLocator.CatalogueRepository.CommentStore,
245245
new PopupChecksUI("Generating class summaries", false),
246246
Activator.CoreIconProvider,
247-
Activator.RepositoryLocator.CatalogueRepository.MEF,
248247
true);
249248
}
250249

@@ -349,7 +348,7 @@ private IAtomicCommand[] GetNewCommands()
349348

350349
private void WindowFactory_TabChanged(object sender, IDockContent newTab)
351350
{
352-
closeToolStripMenuItem.Enabled = newTab != null && newTab is not PersistableToolboxDockContent;
351+
closeToolStripMenuItem.Enabled = newTab is not null and not PersistableToolboxDockContent;
353352
showHelpToolStripMenuItem.Enabled = newTab is RDMPSingleControlTab;
354353

355354
if (newTab is not RDMPSingleControlTab singleObjectControlTab)
@@ -484,8 +483,7 @@ private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
484483
private void ListAllTypesToolStripMenuItem_Click(object sender, EventArgs e)
485484
{
486485
var file = new FileInfo(Path.GetTempFileName());
487-
File.WriteAllLines(file.FullName,
488-
Activator.RepositoryLocator.CatalogueRepository.MEF.GetAllTypes().Select(t => t.FullName));
486+
File.WriteAllLines(file.FullName, Rdmp.Core.Repositories.MEF.GetAllTypes().Select(t => t.FullName));
489487
UsefulStuff.ShowPathInWindowsExplorer(file);
490488
}
491489

Application/ResearchDataManagementPlatform/Program.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,17 @@
1818

1919
namespace ResearchDataManagementPlatform;
2020

21-
internal static class Program
21+
internal static partial class Program
2222
{
23-
[DllImport("kernel32.dll")]
24-
[return: MarshalAs(UnmanagedType.Bool)]
25-
private static extern bool AttachConsole([MarshalAs(UnmanagedType.U4)] int dwProcessId);
23+
[LibraryImport("kernel32.dll")]
24+
private static partial void AttachConsole(int dwProcessId);
2625

2726
/// <summary>
2827
/// The main entry point for the application.
2928
/// </summary>
3029
[STAThread]
3130
private static void Main(string[] args)
3231
{
33-
// if user has the command line built and runnable from the windows
34-
// client then don't load the dlls (or we end up with 2 copies!).
35-
SafeDirectoryCatalog.IgnoreDll = f => Path.GetFileName(f.DirectoryName)?.Equals("cli") == true;
36-
3732
try
3833
{
3934
AttachConsole(-1);
@@ -47,14 +42,14 @@ private static void Main(string[] args)
4742

4843
UsefulStuff.GetParser()
4944
.ParseArguments<ResearchDataManagementPlatformOptions>(args)
50-
.MapResult(RunApp, err => -1);
45+
.MapResult(RunApp, _ => -1);
5146
}
5247

5348
private static object RunApp(ResearchDataManagementPlatformOptions arg)
5449
{
5550
try
5651
{
57-
arg.PopulateConnectionStringsFromYamlIfMissing(new ThrowImmediatelyCheckNotifier());
52+
arg.PopulateConnectionStringsFromYamlIfMissing(ThrowImmediatelyCheckNotifier.Quiet);
5853
}
5954
catch (Exception ex)
6055
{
@@ -63,11 +58,14 @@ private static object RunApp(ResearchDataManagementPlatformOptions arg)
6358
}
6459

6560
var bootStrapper =
66-
new RDMPBootStrapper<RDMPMainForm>(
67-
new EnvironmentInfo(PluginFolders.Main | PluginFolders.Windows),
68-
arg);
61+
new RDMPBootStrapper(arg, locator =>
62+
{
63+
var form = new RDMPMainForm();
64+
form.SetRepositoryLocator(locator);
65+
return form;
66+
});
6967

70-
bootStrapper.Show(false);
68+
bootStrapper.Show();
7169
return 0;
7270
}
7371
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using System.Runtime.InteropServices;
22

3-
// Setting ComVisible to false makes the types in this assembly not visible
4-
// to COM components. If you need to access a type in this assembly from
3+
// Setting ComVisible to false makes the types in this assembly not visible
4+
// to COM components. If you need to access a type in this assembly from
55
// COM, set the ComVisible attribute to true on that type.
66
[assembly: ComVisible(false)]
77

8-
// The following GUID is for the ID of the typelib if this project is exposed to COM
8+
// The following GUID is for the ID of the type library if this project is exposed to COM
99
[assembly: Guid("cac9817c-fc66-48e8-9333-c740af6ab5b9")]

Application/ResearchDataManagementPlatform/RDMP.nuspec

Lines changed: 0 additions & 16 deletions
This file was deleted.

Application/ResearchDataManagementPlatform/RDMPMainForm.cs

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Drawing;
99
using System.IO;
1010
using System.Linq;
11-
using System.Reflection;
1211
using System.Text;
1312
using System.Windows.Forms;
1413
using Rdmp.Core.Curation.Data;
@@ -34,13 +33,12 @@ namespace ResearchDataManagementPlatform;
3433
/// <summary>
3534
/// Main entry point into the RDMP software. Hosts all tab collections and document windows for all RDMP tasks. See CatalogueCollectionUI , DataExportCollectionUI ,
3635
/// TableInfoCollectionUI , LoadMetadataCollectionUI and CohortIdentificationCollectionUI
37-
/// See
36+
/// See
3837
/// </summary>
3938
public partial class RDMPMainForm : RDMPForm
4039
{
4140
private readonly PersistenceDecisionFactory _persistenceFactory = new();
42-
private ITheme _theme;
43-
41+
private readonly ITheme _theme;
4442
private IRDMPPlatformRepositoryServiceLocator RepositoryLocator { get; set; }
4543

4644
/// <summary>
@@ -120,8 +118,7 @@ private void RDMPMainForm_Load(object sender, EventArgs e)
120118
var database = connectedTo.DiscoveredServer?.GetCurrentDatabase();
121119
var instanceDescription = "";
122120

123-
var connectionStringsFileLoaded =
124-
RDMPBootStrapper<RDMPMainForm>.ApplicationArguments?.ConnectionStringsFileLoaded;
121+
var connectionStringsFileLoaded = RDMPBootStrapper.ApplicationArguments?.ConnectionStringsFileLoaded;
125122
if (connectionStringsFileLoaded != null)
126123
instanceDescription =
127124
$" - {connectionStringsFileLoaded.Name ?? connectionStringsFileLoaded.FileLoaded.Name}";
@@ -144,12 +141,11 @@ private void RDMPMainForm_Load(object sender, EventArgs e)
144141
//if there is no persist file or user wants to show the home screen always on startup
145142
if (!_persistenceFile.Exists || UserSettings.ShowHomeOnStartup)
146143
_windowManager.PopHome();
147-
else
144+
else if (_persistenceFile.Exists)
148145
try
149146
{
150-
if (_persistenceFile.Exists)
151-
LoadFromXml(new FileStream(_persistenceFile.FullName, FileMode.Open));
152147
//load the state using the method
148+
LoadFromXml(new FileStream(_persistenceFile.FullName, FileMode.Open));
153149
}
154150
catch (Exception ex)
155151
{
@@ -170,18 +166,18 @@ private void RDMPMainForm_Load(object sender, EventArgs e)
170166
public override string Text
171167
{
172168
get => base.Text;
173-
set => base.Text = (value + " v" + _version + " " + _connectedTo).Trim();
169+
set => base.Text = $"{value} v{_version} {_connectedTo}".Trim();
174170
}
175171

176-
public void LoadFromXml(Stream stream)
172+
private void LoadFromXml(Stream stream)
177173
{
178174
if (dockPanel1.DocumentStyle == DocumentStyle.SystemMdi)
179175
foreach (var form in MdiChildren)
180176
form.Close();
181177
else
182178
foreach (var document in dockPanel1.DocumentsToArray())
183179
{
184-
// IMPORANT: dispose all panes.
180+
// IMPORTANT: dispose all panes.
185181
document.DockHandler.DockPanel = null;
186182
document.DockHandler.Close();
187183
}
@@ -208,45 +204,24 @@ public void LoadFromXml(WindowLayout target)
208204
var uniEncoding = new UnicodeEncoding();
209205

210206
// You might not want to use the outer using statement that I have
211-
// I wasn't sure how long you would need the MemoryStream object
212-
using (var ms = new MemoryStream())
213-
{
214-
var sw = new StreamWriter(ms, uniEncoding);
215-
try
216-
{
217-
sw.Write(target.LayoutData);
218-
sw.Flush(); //otherwise you are risking empty stream
219-
ms.Seek(0, SeekOrigin.Begin);
220-
221-
LoadFromXml(ms);
222-
}
223-
finally
224-
{
225-
sw.Dispose();
226-
}
227-
}
207+
// I wasn't sure how long you would need the MemoryStream object
208+
using var ms = new MemoryStream();
209+
using var sw = new StreamWriter(ms, uniEncoding);
210+
sw.Write(target.LayoutData);
211+
sw.Flush(); //otherwise you are risking empty stream
212+
ms.Seek(0, SeekOrigin.Begin);
213+
LoadFromXml(ms);
228214
}
229215

230216

231217
public string GetCurrentLayoutXml()
232218
{
233219
var uniEncoding = new UnicodeEncoding();
234220

235-
using (var ms = new MemoryStream())
236-
{
237-
dockPanel1.SaveAsXml(ms, uniEncoding);
238-
239-
ms.Seek(0, SeekOrigin.Begin);
240-
241-
try
242-
{
243-
return new StreamReader(ms).ReadToEnd();
244-
}
245-
finally
246-
{
247-
ms.Dispose();
248-
}
249-
}
221+
using var ms = new MemoryStream();
222+
dockPanel1.SaveAsXml(ms, uniEncoding);
223+
ms.Seek(0, SeekOrigin.Begin);
224+
return new StreamReader(ms).ReadToEnd();
250225
}
251226

252227
private void CloseForm(object sender, FormClosingEventArgs e)
@@ -265,13 +240,10 @@ private void CloseForm(object sender, FormClosingEventArgs e)
265240

266241
try
267242
{
268-
if (_persistenceFile != null)
269-
{
270-
if (!_persistenceFile.Directory.Exists)
271-
_persistenceFile.Directory.Create();
272-
273-
dockPanel1.SaveAsXml(_persistenceFile.FullName); //save when Form closes
274-
}
243+
if (_persistenceFile == null) return;
244+
if (_persistenceFile.Directory?.Exists == false)
245+
_persistenceFile.Directory.Create();
246+
dockPanel1.SaveAsXml(_persistenceFile.FullName); //save when Form closes
275247
}
276248
catch (Exception ex)
277249
{

0 commit comments

Comments
 (0)