Skip to content

Commit 274e40d

Browse files
committed
Merge branch 'feature/net8_v5' into develop
2 parents e1913e4 + ffab207 commit 274e40d

724 files changed

Lines changed: 27010 additions & 20144 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ dotnet_style_object_initializer = true
5151
dotnet_style_operator_placement_when_wrapping = beginning_of_line
5252
dotnet_style_prefer_auto_properties = true:suggestion
5353
dotnet_style_prefer_compound_assignment = true
54+
dotnet_style_prefer_collection_expression = false
5455
dotnet_style_prefer_conditional_expression_over_assignment = true
5556
dotnet_style_prefer_conditional_expression_over_return = true
5657
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
@@ -225,3 +226,15 @@ dotnet_naming_style.begins_with_i.required_prefix = I
225226
dotnet_naming_style.begins_with_i.required_suffix =
226227
dotnet_naming_style.begins_with_i.word_separator =
227228
dotnet_naming_style.begins_with_i.capitalization = pascal_case
229+
230+
# IDE0055: Fix formatting
231+
dotnet_diagnostic.IDE0055.severity = none
232+
233+
# CA1507: Use nameof to express symbol names
234+
dotnet_diagnostic.CA1507.severity = none
235+
236+
# IDE0057: Use range operator
237+
dotnet_diagnostic.IDE0057.severity = none
238+
239+
# IDE0056: Use index operator
240+
dotnet_diagnostic.IDE0056.severity = none

BuildInstaller/BuildInstaller.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
</PropertyGroup>
3838
<ItemGroup>
3939
<PackageReference Include="Microsoft.CSharp" />
40-
<PackageReference Include="System.Runtime" />
41-
<PackageReference Include="System.Runtime.Extensions" />
4240
</ItemGroup>
4341

4442
<!--Check for unused dependencies in Directory.Packages.props-->

CargoMonitor/CargoMonitor.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ namespace EddiCargoMonitor
2626
public class CargoMonitor : IEddiMonitor
2727
{
2828
// Observable collection for us to handle changes
29-
public ObservableCollection<Cargo> inventory { get; private set; } = new ObservableCollection<Cargo>();
29+
public ObservableCollection<Cargo> inventory { get; private set; } = [];
3030
public int cargoCarried => inventory.Sum(c => c.total);
3131
private DateTime updateDat;
3232

33-
private static readonly object inventoryLock = new object();
33+
private static readonly object inventoryLock = new();
3434
[UsedImplicitly] public event EventHandler InventoryUpdatedEvent;
3535

3636
public string MonitorName()
@@ -75,7 +75,7 @@ public CargoMonitor(CargoMonitorConfiguration configuration = null)
7575

7676
private void ConfigChanged ( object sender, PropertyChangedEventArgs e )
7777
{
78-
if ( e.PropertyName.Equals( nameof(ConfigService.Instance.missionMonitorConfiguration) ) )
78+
if ( e.PropertyName?.Equals( nameof(ConfigService.Instance.missionMonitorConfiguration) ) ?? false )
7979
{
8080
CalculateCargoNeeds();
8181
}
@@ -237,7 +237,7 @@ internal void _handleCargoEvent(CargoEvent @event)
237237
}
238238

239239
// Update existing cargo in the manifest
240-
while (infoList.Any())
240+
while ( infoList.Count > 0 )
241241
{
242242
var name = infoList.ToList().First().name;
243243
var cargoInfo = infoList.Where(i => i.name.Equals(name, StringComparison.OrdinalIgnoreCase)).ToList();
@@ -536,8 +536,8 @@ public IDictionary<string, Tuple<Type, object>> GetVariables ()
536536
{
537537
return new Dictionary<string, Tuple<Type, object>>
538538
{
539-
["inventory"] = new Tuple<Type, object>(typeof(List<Cargo>), inventory.ToList() ),
540-
["cargoCarried"] = new Tuple<Type, object>(typeof(int), cargoCarried)
539+
["inventory"] = new(typeof(List<Cargo>), inventory.ToList() ),
540+
["cargoCarried"] = new(typeof(int), cargoCarried)
541541
};
542542
}
543543
}
@@ -564,7 +564,7 @@ private void readInventory(CargoMonitorConfiguration configuration = null)
564564
lock (inventoryLock)
565565
{
566566
// Obtain current cargo inventory from configuration
567-
configuration = configuration ?? ConfigService.Instance.cargoMonitorConfiguration;
567+
configuration ??= ConfigService.Instance.cargoMonitorConfiguration;
568568
updateDat = configuration.updatedat;
569569

570570
// Build a new inventory
@@ -573,10 +573,7 @@ private void readInventory(CargoMonitorConfiguration configuration = null)
573573
// Start with the materials we have in the log
574574
foreach (var cargo in configuration.cargo)
575575
{
576-
if (cargo.commodityDef == null)
577-
{
578-
cargo.commodityDef = CommodityDefinition.FromEDName(cargo.edname);
579-
}
576+
cargo.commodityDef ??= CommodityDefinition.FromEDName(cargo.edname);
580577
newInventory.Add(cargo);
581578
}
582579

@@ -632,10 +629,9 @@ private void _RemoveCargoWithEDName(string edname)
632629
{
633630
if (edname != null)
634631
{
635-
edname = edname.ToLowerInvariant();
636632
for (var i = 0; i < inventory.Count; i++)
637633
{
638-
if (inventory[i].edname.ToLowerInvariant() == edname)
634+
if ( string.Equals( inventory[ i ].edname, edname, StringComparison.InvariantCultureIgnoreCase ) )
639635
{
640636
inventory.RemoveAt(i);
641637
break;
@@ -652,8 +648,8 @@ public Cargo GetCargoWithEDName(string edname)
652648
{
653649
return null;
654650
}
655-
edname = edname.ToLowerInvariant();
656-
return inventory.FirstOrDefault(c => c.edname.ToLowerInvariant() == edname);
651+
return inventory.FirstOrDefault(c =>
652+
string.Equals( c.edname, edname, StringComparison.InvariantCultureIgnoreCase ) );
657653
}
658654

659655
[CanBeNull]
@@ -663,7 +659,7 @@ public Cargo GetCargoWithMissionId ( ulong missionid, out int amount )
663659
foreach ( var cargo in inventory.ToList() )
664660
{
665661
var missionCargo = cargo.missionCargo.Where( c => c.Key == missionid ).ToList();
666-
if ( missionCargo.Any() )
662+
if ( missionCargo.Count > 0 )
667663
{
668664
amount = missionCargo.Sum( c => c.Value );
669665
return cargo;
@@ -672,7 +668,7 @@ public Cargo GetCargoWithMissionId ( ulong missionid, out int amount )
672668
return null;
673669
}
674670

675-
private void UpdateCargoFromInfo ( Cargo cargo, List<CargoInfoItem> infoList )
671+
private static void UpdateCargoFromInfo ( Cargo cargo, List<CargoInfoItem> infoList )
676672
{
677673
cargo.missionCargo = infoList.Where( i => i.missionid != null ).ToDictionary( i => (ulong)i.missionid, i => i.count );
678674
cargo.stolen = infoList.Where( i => i.missionid == null ).Sum( i => i.stolen );
@@ -686,8 +682,9 @@ private void CalculateCargoNeeds ()
686682
var missionsConfig = ConfigService.Instance.missionMonitorConfiguration;
687683
var missions = missionsConfig.missions
688684
.Where( m =>
689-
m?.CommodityDefinition != null &&
690-
m.amount != null &&
685+
m != null &&
686+
m.CommodityDefinition != null &&
687+
m.amount is not null &&
691688
m.delivered < m.amount &&
692689
!m.communal )
693690
.ToList();

CargoMonitor/ConfigurationWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<UserControl x:Class="EddiCargoMonitor.ConfigurationWindow"
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:System="clr-namespace:System;assembly=mscorlib"
54
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
65
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
76
xmlns:local="clr-namespace:EddiCargoMonitor"
87
xmlns:resx="clr-namespace:EddiCargoMonitor.Properties"
98
xmlns:utility="clr-namespace:Utilities;assembly=Utilities"
109
xmlns:eddiDataDefinitions="clr-namespace:EddiDataDefinitions;assembly=EddiDataDefinitions"
10+
xmlns:System="clr-namespace:System;assembly=System.Runtime"
1111
mc:Ignorable="d"
1212
d:DesignHeight="300" d:DesignWidth="800">
1313
<DockPanel LastChildFill="True" Background="#FFE5E5E5" Margin="0,5">

CargoMonitor/ConfigurationWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace EddiCargoMonitor
99
/// </summary>
1010
public partial class ConfigurationWindow : UserControl
1111
{
12-
private CargoMonitor cargoMonitor()
12+
private static CargoMonitor cargoMonitor()
1313
{
1414
return (CargoMonitor)EDDI.Instance.ObtainMonitor("Cargo monitor");
1515
}

CargoMonitor/EddiCargoMonitor.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
<PackageReference Include="JetBrains.Annotations" />
2323
<PackageReference Include="Microsoft.CSharp" />
2424
<PackageReference Include="Newtonsoft.Json" />
25-
<PackageReference Include="System.Runtime" />
26-
<PackageReference Include="System.Runtime.Extensions" />
2725
</ItemGroup>
2826
<ItemGroup>
2927
<Compile Update="Properties\CargoMonitor.Designer.cs">

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Full details of the variables available for each noted event, and VoiceAttack integrations, are available in the individual [event pages](https://github.com/EDCD/EDDI/wiki/Events).
44

5+
## 5.0.0
6+
* Core
7+
* Target framework updated to .Net 8.
8+
* VoiceAttack Responder
9+
* (**BREAKING CHANGE**) Updated to target VoiceAttack 2.0.0+. VoiceAttack 1.X is no longer supported.
10+
* Under the hood, EDDI now runs as a separate process from VoiceAttack. Only the plugin component of EDDI runs within the VoiceAttack process. This should improve stability and performance for both EDDI and VoiceAttack.
11+
512
## 4.1.9
613
* Core
714
* Add support for the Kestrel Mk. II.

CommanderMonitor/CommanderMonitor.cs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ namespace EddiCommanderMonitor
2323
[UsedImplicitly]
2424
public class CommanderMonitor : IEddiMonitor, INotifyPropertyChanged
2525
{
26-
private static readonly object commanderLock = new object();
27-
private readonly CancellationTokenSource cts = new CancellationTokenSource();
26+
private static readonly object commanderLock = new();
27+
private readonly CancellationTokenSource cts = new();
2828

2929
#region Monitored Variables
3030

@@ -84,12 +84,12 @@ public class GenderOption
8484
}
8585

8686
[UsedImplicitly]
87-
public static ObservableCollection<GenderOption> GenderOptions { get; set; } = new ObservableCollection<GenderOption>
88-
{
89-
new GenderOption { Gender = Gender.Male, DisplayName = Properties.Resources.tab_commander_gender_m },
90-
new GenderOption { Gender = Gender.Female, DisplayName = Properties.Resources.tab_commander_gender_f },
91-
new GenderOption { Gender = Gender.Neither, DisplayName = Properties.Resources.tab_commander_gender_n }
92-
};
87+
public static ObservableCollection<GenderOption> GenderOptions { get; set; } =
88+
[
89+
new() { Gender = Gender.Male, DisplayName = Properties.Resources.tab_commander_gender_m },
90+
new() { Gender = Gender.Female, DisplayName = Properties.Resources.tab_commander_gender_f },
91+
new() { Gender = Gender.Neither, DisplayName = Properties.Resources.tab_commander_gender_n }
92+
];
9393

9494
[CanBeNull]
9595
public StarSystem HomeStarSystem // May be null when the commander hasn't set a home star system
@@ -155,7 +155,7 @@ private async Task FetchHomeSystemAsync ( string systemName )
155155

156156
private static bool _isFetchingHomeSystem;
157157

158-
public ObservableCollection<Station> HomeStationOptions { get; } = new ObservableCollection<Station>();
158+
public ObservableCollection<Station> HomeStationOptions { get; } = [ ];
159159

160160
private void UpdateHomeStationOptions ()
161161
{
@@ -245,7 +245,8 @@ private async Task FetchSquadronSystemAsync(string systemName)
245245
// Ensure collection modifications happen on the UI thread
246246
if ( System.Windows.Application.Current?.Dispatcher?.CheckAccess() == false )
247247
{
248-
await System.Windows.Application.Current.Dispatcher.InvokeAsync( () => FetchSquadronSystemAsync(systemName) );
248+
await System.Windows.Application.Current.Dispatcher.InvokeAsync( async () =>
249+
await FetchSquadronSystemAsync( systemName ) );
249250
return;
250251
}
251252

@@ -273,7 +274,7 @@ private async Task FetchSquadronSystemAsync(string systemName)
273274

274275
private static bool _isFetchingSquadronSystem;
275276

276-
public ObservableCollection<Faction> SquadronFactions { get; } = new ObservableCollection<Faction>();
277+
public ObservableCollection<Faction> SquadronFactions { get; } = [ ];
277278

278279
private void UpdateSquadronFactions ()
279280
{
@@ -311,8 +312,8 @@ public Faction SelectedSquadronFaction
311312
}
312313
private Faction _selectedSquadronFaction;
313314

314-
public ObservableCollection<Power> SquadronPowers => new ObservableCollection<Power>( Power.AllOfThem
315-
.Except( new [] { Power.None } )
315+
public static ObservableCollection<Power> SquadronPowers => new( Power.AllOfThem
316+
.Except( [ Power.None ] )
316317
.OrderBy( p => p.localizedName )
317318
.Prepend( Power.None )
318319
.ToHashSet() );
@@ -487,7 +488,7 @@ private void handleCarrierJumpedEvent ( CarrierJumpedEvent @event )
487488
{
488489
SetCommanderTitle( @event.controllingsystemfaction.Allegiance );
489490
}
490-
if ( ( @event.docked || @event.onFoot ) && @event.factions.Any() && EDDI.Instance.CurrentStarSystem != null )
491+
if ( ( @event.docked || @event.onFoot ) && @event.factions.Count > 0 && EDDI.Instance.CurrentStarSystem != null )
491492
{
492493
if ( @event.timestamp >= updatedAt &&
493494
TryUpdateSquadronHomeSystem( @event.systemAddress, @event.factions ) )
@@ -603,7 +604,7 @@ private void handleJumpedEvent ( JumpedEvent @event )
603604
{
604605
SetCommanderTitle( @event.controllingfaction?.Allegiance );
605606
}
606-
if ( @event.factions.Any() && EDDI.Instance.CurrentStarSystem != null )
607+
if ( @event.factions.Count > 0 && EDDI.Instance.CurrentStarSystem != null )
607608
{
608609
if ( @event.timestamp >= updatedAt &&
609610
TryUpdateSquadronHomeSystem( @event.systemAddress, @event.factions ) )
@@ -619,7 +620,7 @@ private void handleLocationEvent ( LocationEvent @event )
619620
{
620621
SetCommanderTitle( @event.controllingsystemfaction.Allegiance );
621622
}
622-
if ( @event.factions.Any() && EDDI.Instance.CurrentStarSystem != null )
623+
if ( @event.factions.Count > 0 && EDDI.Instance.CurrentStarSystem != null )
623624
{
624625
if ( @event.timestamp >= updatedAt &&
625626
TryUpdateSquadronHomeSystem( @event.systemAddress, @event.factions ) )
@@ -786,7 +787,7 @@ private void handleSquadronStatusEvent ( SquadronStatusEvent @event )
786787

787788
private bool TryUpdateSquadronHomeSystem ( ulong currentSystemAddress, List<Faction> systemFactions )
788789
{
789-
bool update = false;
790+
var update = false;
790791

791792
// Check if current system is inhabited by or HQ for squadron faction
792793
var squadronFaction = systemFactions.FirstOrDefault( f =>
@@ -875,12 +876,14 @@ private void SetCommanderTitle ( Superpower controllingFactionAllegiance )
875876
if ( controllingFactionAllegiance != null )
876877
{
877878
if ( controllingFactionAllegiance.invariantName == Superpower.Federation.invariantName &&
878-
Cmdr.federationrating != null && Cmdr.federationrating.rank > minFederationRankForTitle )
879+
Cmdr.federationrating is { } rating &&
880+
rating.rank > minFederationRankForTitle )
879881
{
880882
Cmdr.title = Cmdr.federationrating.localizedName;
881883
}
882884
else if ( controllingFactionAllegiance.invariantName == Superpower.Empire.invariantName &&
883-
Cmdr.empirerating != null && Cmdr.empirerating.rank > minEmpireRankForTitle )
885+
Cmdr.empirerating is { } empireRating &&
886+
empireRating.rank > minEmpireRankForTitle )
884887
{
885888
Cmdr.title = Cmdr.empirerating.maleRank.localizedName;
886889
}
@@ -891,7 +894,7 @@ private void SetCommanderTitle ( Superpower controllingFactionAllegiance )
891894
private Commander ReadCommander ( CommanderConfiguration configuration = null )
892895
{
893896
// Obtain current commander from our configuration
894-
configuration = configuration ?? ConfigService.Instance.commanderConfiguration;
897+
configuration ??= ConfigService.Instance.commanderConfiguration;
895898
var commander = new Commander
896899
{
897900
name = configuration.commanderName,

CommanderMonitor/EddiCommanderMonitor.csproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@
1111
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
1212
<OutputPath>..\bin\Release\</OutputPath>
1313
</PropertyGroup>
14-
<ItemGroup>
15-
<Reference Include="PresentationCore" />
16-
<Reference Include="PresentationFramework" />
17-
<Reference Include="System" />
18-
<Reference Include="System.Core" />
19-
<Reference Include="System.Xaml" />
20-
<Reference Include="System.Xml.Linq" />
21-
<Reference Include="System.Data.DataSetExtensions" />
22-
<Reference Include="Microsoft.CSharp" />
23-
<Reference Include="System.Data" />
24-
<Reference Include="System.Net.Http" />
25-
<Reference Include="System.Xml" />
26-
<Reference Include="WindowsBase" />
27-
</ItemGroup>
2814
<ItemGroup>
2915
<ProjectReference Include="..\ConfigService\EddiConfigService.csproj" />
3016
<ProjectReference Include="..\DataDefinitions\EddiDataDefinitions.csproj" />

CompanionAppService/CompanionAppCredentials.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class CompanionAppCredentials
3030
public static CompanionAppCredentials Load(string filepath = null)
3131
{
3232
CompanionAppCredentials credentials = null;
33-
filepath = filepath ?? defaultPath;
33+
filepath ??= defaultPath;
3434

3535
string data = null;
3636
if (System.IO.File.Exists(filepath))
@@ -75,9 +75,9 @@ public void Clear()
7575
/// </summary>
7676
public void Save(string filename = null)
7777
{
78-
filename = filename ?? dataPath ?? defaultPath;
78+
filename ??= dataPath ?? defaultPath;
7979

80-
string json = JsonConvert.SerializeObject(this, Formatting.Indented);
80+
var json = JsonConvert.SerializeObject(this, Formatting.Indented);
8181
Files.Write(filename, json);
8282
}
8383
}

0 commit comments

Comments
 (0)