Skip to content

Commit b19016b

Browse files
committed
Remove references to PrivateObject and PrivateType classes
These are not supported in later versions of .Net
1 parent ecc3075 commit b19016b

11 files changed

Lines changed: 18 additions & 25 deletions

File tree

EDDI/App.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
xmlns:local="clr-namespace:Eddi"
55
StartupUri="EddiUI.MainWindow.xaml">
66
<Application.Resources>
7-
87
</Application.Resources>
98
</Application>

EddiInaraService/InaraService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public List<InaraResponse> SendEventBatch ( List<InaraAPIEvent> events, InaraCon
187187
return inaraResponses;
188188
}
189189

190-
private List<InaraAPIEvent> IndexAndFilterAPIEvents(List<InaraAPIEvent> events, InaraConfiguration inaraConfiguration)
190+
internal List<InaraAPIEvent> IndexAndFilterAPIEvents(List<InaraAPIEvent> events, InaraConfiguration inaraConfiguration)
191191
{
192192
// If we don't have a commander name then only use `get` events and re-enqueue the rest.
193193
if (string.IsNullOrEmpty(inaraConfiguration.commanderName))

JournalMonitor/JournalMonitor.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
using System.Collections.Concurrent;
1010
using System.Collections.Generic;
1111
using System.Linq;
12+
using System.Runtime.CompilerServices;
1213
using System.Runtime.InteropServices;
1314
using System.Text.RegularExpressions;
1415
using System.Threading;
1516
using System.Threading.Tasks;
1617
using System.Windows.Controls;
1718
using Utilities;
1819

20+
[assembly: InternalsVisibleTo("Tests")]
1921
namespace EddiJournalMonitor
2022
{
2123
public class JournalMonitor : LogMonitor, IEddiMonitor
@@ -37,7 +39,7 @@ private enum ShipyardType { [UsedImplicitly] ShipsHere, [UsedImplicitly] ShipsRe
3739
private static readonly Dictionary<long, CancellationTokenSource> carrierJumpCancellationTokenSources =
3840
new Dictionary<long, CancellationTokenSource>();
3941

40-
private static CancellationTokenSource ShipShutdownCancellationTokenSource;
42+
internal static CancellationTokenSource ShipShutdownCancellationTokenSource;
4143

4244
private static void ForwardJournalEntries ( IList<string> lines, Action<Event> callback, bool isLogLoadEventBatch )
4345
{

SpeechResponder/CopyPersonalityWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace EddiSpeechResponder
77
{
8-
using resx = Properties.SpeechResponder;
8+
using resX = Properties.SpeechResponder;
99

1010
/// <summary>
1111
/// Interaction logic for CopyPersonalityWindow.xaml
@@ -114,12 +114,12 @@ string ValidatePersonalityName()
114114

115115
if (string.IsNullOrEmpty(trimmedName))
116116
{
117-
return resx.validation_tooltip_name_empty;
117+
return resX.validation_tooltip_name_empty;
118118
}
119119

120120
if (existingNames.Contains(trimmedName))
121121
{
122-
return resx.validation_tooltip_name_taken;
122+
return resX.validation_tooltip_name_taken;
123123
}
124124

125125
return string.Empty;

SpeechResponder/CustomFunctions/ShipCallsign.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class ShipCallsign : ICustomFunction
5151
}
5252
}, 0, 2);
5353

54-
private static string phoneticCallsign(Ship ship, string id)
54+
internal static string phoneticCallsign(Ship ship, string id)
5555
{
5656
if (string.IsNullOrEmpty(ship?.manufacturer) || string.IsNullOrEmpty(id)) { return string.Empty; }
5757

Tests/CustomFunctions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ private string ResolveScript(string script, Dictionary<string, Tuple<Type, Value
3535
public void TestShipCallsignFunction(string shipModel, string id, string expected)
3636
{
3737
var ship = ShipDefinitions.FromEDModel(shipModel);
38-
var privateType = new PrivateType(typeof(ShipCallsign));
39-
Assert.AreEqual(expected, (string)privateType.InvokeStatic("phoneticCallsign", new object[] { ship, id }));
38+
Assert.AreEqual( expected, ShipCallsign.phoneticCallsign( ship, id ) );
4039
}
4140

4241
[DataTestMethod]

Tests/InaraTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ public void TestIndexAndFilterAPIEvents()
2828
new InaraAPIEvent(DateTime.UtcNow, "getCommanderProfile", new Dictionary<string, object> { { "searchName", "Artie" } }),
2929
new InaraAPIEvent(DateTime.UtcNow, "addCommanderCombatDeath", new Dictionary<string, object> { { "starsystemName", "LP 932-12" }, { "opponentName", "Vincent Van Stoi" } })
3030
};
31-
var privateInaraService = new PrivateObject(typeof(InaraService));
32-
var results = (List<InaraAPIEvent>)privateInaraService.Invoke("IndexAndFilterAPIEvents", inaraAPIEvents, new InaraConfiguration() );
33-
31+
32+
var results = ((InaraService)inaraService).IndexAndFilterAPIEvents( inaraAPIEvents, new InaraConfiguration() );
3433
if (results?.Count == 2)
3534
{
3635
// Check that appropriate response IDs were assigned to each API event

Tests/JournalMonitorTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2482,9 +2482,7 @@ public void TestExplorationSequence()
24822482
[TestMethod, DoNotParallelize]
24832483
public void TestRepeatedShipShutdownEvents ()
24842484
{
2485-
var privateType = new PrivateType( typeof(JournalMonitor) );
2486-
// ReSharper disable once AssignNullToNotNullAttribute - CancellationTokenSource is nullable.
2487-
privateType.SetStaticFieldOrProperty( "ShipShutdownCancellationTokenSource", null );
2485+
JournalMonitor.ShipShutdownCancellationTokenSource = null;
24882486

24892487
// Trigger a `ShipShutdown` event.
24902488
var events = JournalMonitor.ParseJournalEntries( new [] {@"{ ""timestamp"":""2023-11-24T20:22:45Z"", ""event"":""SystemsShutdown"" }" } );
@@ -2508,9 +2506,7 @@ public void TestRepeatedShipShutdownEvents ()
25082506
[TestMethod, DoNotParallelize]
25092507
public void TestShipShutdownThargoidTitanPulse ()
25102508
{
2511-
var privateType = new PrivateType( typeof(JournalMonitor) );
2512-
// ReSharper disable once AssignNullToNotNullAttribute - CancellationTokenSource is nullable.
2513-
privateType.SetStaticFieldOrProperty( "ShipShutdownCancellationTokenSource", null );
2509+
JournalMonitor.ShipShutdownCancellationTokenSource = null;
25142510

25152511
//The `SystemsShutdown` event should be ignored because it is followed immediately by a `MaterialCollected` event for the material `tg_shutdowndata` and no shutdown in fact occurs for this circumstance.
25162512
var lines = new[]

Tests/OAuthClientIDTests.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ public class OAuthClientIDTests
88
[TestMethod]
99
public void TestClientIDNotNull()
1010
{
11-
var clientIDClass = new PrivateType(typeof(EddiCompanionAppService.ClientId));
12-
var clientID = clientIDClass.GetStaticField("ID");
13-
Assert.IsInstanceOfType(clientID, typeof(string));
11+
var clientID = EddiCompanionAppService.ClientId.ID;
12+
Assert.IsInstanceOfType( clientID, typeof(string));
1413
Assert.IsNotNull( clientID );
1514
}
1615
}

Tests/TelemetryTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Newtonsoft.Json.Linq;
44
using System;
55
using System.Collections.Generic;
6-
using System.Threading.Tasks;
76
using Utilities;
87

98
namespace Tests
@@ -13,8 +12,7 @@ public class TelemetryTests : TestBase
1312
{
1413
private Dictionary<string, object> PrepTelemetryData(object data)
1514
{
16-
var privateType = new PrivateType(typeof(Logging));
17-
var result = (Task<Dictionary<string, object>>)privateType.InvokeStatic("PrepareData", JToken.FromObject(data) );
15+
var result = Logging.PrepareData( JToken.FromObject( data ) );
1816
return result.Result;
1917
}
2018

0 commit comments

Comments
 (0)