Skip to content

Commit 08f0d3a

Browse files
committed
Mark IRomAsset.RomPath as [Obsolete] and mute existing warnings
1 parent 7a89e1e commit 08f0d3a

File tree

9 files changed

+52
-12
lines changed

9 files changed

+52
-12
lines changed

src/BizHawk.Emulation.Cores/Arcades/MAME/MAME.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public partial class MAME : IRomInfo
2222
[CoreConstructor(VSystemID.Raw.Arcade)]
2323
public MAME(CoreLoadParameters<object, MAMESyncSettings> lp)
2424
{
25+
#pragma warning disable CS0618
2526
_gameFileName = Path.GetFileName(lp.Roms[0].RomPath.SubstringAfter('|')).ToLowerInvariant();
27+
#pragma warning restore CS0618
2628
_syncSettings = lp.SyncSettings ?? new();
2729

2830
ServiceProvider = new BasicServiceProvider(this);
@@ -174,8 +176,10 @@ static byte[] MakeRomData(IRomAsset rom)
174176
// mame expects chd files in a folder of the game name
175177
string MakeFileName(IRomAsset rom)
176178
=> rom.Extension.ToLowerInvariant() is ".chd"
179+
#pragma warning disable CS0618
177180
? gameName + '/' + Path.GetFileNameWithoutExtension(rom.RomPath.SubstringAfter('|')).ToLowerInvariant() + rom.Extension.ToLowerInvariant()
178181
: Path.GetFileNameWithoutExtension(rom.RomPath.SubstringAfter('|')).ToLowerInvariant() + rom.Extension.ToLowerInvariant();
182+
#pragma warning restore CS0618
179183

180184
foreach (var rom in roms)
181185
{

src/BizHawk.Emulation.Cores/Computers/Amiga/UAE.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ public partial class UAE : WaterboxCore
5555
private bool _nextDrivePressed;
5656
private int _correctedWidth;
5757
private string _chipsetCompatible = "";
58-
private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|'));
58+
59+
private string GetFullName(IRomAsset rom)
60+
#pragma warning disable CS0618
61+
=> Path.GetFileName(rom.RomPath.SubstringAfter('|'));
62+
#pragma warning restore CS0618
5963

6064
public override int VirtualWidth => _correctedWidth;
6165

src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public sealed partial class DOSBox : WaterboxCore
5050
private int _currentCDROM = 0;
5151
private bool _disposed;
5252

53-
private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|'));
53+
private string GetFullName(IRomAsset rom)
54+
#pragma warning disable CS0618
55+
=> Path.GetFileName(rom.RomPath.SubstringAfter('|'));
56+
#pragma warning restore CS0618
57+
5458
private string GetFullName(IDiscAsset disk) => Path.GetFileName(disk.DiscData.Name.SubstringAfter('|'));
5559

5660
// CD Handling logic
@@ -81,7 +85,10 @@ public DOSBox(CoreLoadParameters<object, SyncSettings> lp)
8185
// Parsing rom files
8286
foreach (var file in _romAssets)
8387
{
84-
switch (Path.GetExtension(file.RomPath))
88+
#pragma warning disable CS0618
89+
var filePath = file.RomPath;
90+
#pragma warning restore CS0618
91+
switch (Path.GetExtension(filePath))
8592
{
8693
case ".ima" or ".img" or ".xdf" or ".dmf" or ".fdd" or ".fdi" or ".nfd" or ".d88":
8794
_floppyDiskImageFiles.Add(file);
@@ -96,7 +103,7 @@ public DOSBox(CoreLoadParameters<object, SyncSettings> lp)
96103
break;
97104

98105
default:
99-
throw new Exception($"Unrecognized input file provided: '{file.RomPath}'");
106+
throw new Exception($"Provided file was not recognised: \"{filePath}\"");
100107
}
101108
}
102109

@@ -209,7 +216,9 @@ public DOSBox(CoreLoadParameters<object, SyncSettings> lp)
209216
string floppyMountLine = "imgmount a ";
210217
foreach (var file in _floppyDiskImageFiles)
211218
{
219+
#pragma warning disable CS0618
212220
string floppyNewName = $"{FileNames.FD}{_floppyDiskCount}{Path.GetExtension(file.RomPath)}";
221+
#pragma warning restore CS0618
213222
_exe.AddReadonlyFile(file.FileData, floppyNewName);
214223
floppyMountLine += floppyNewName + " ";
215224
_floppyDiskCount++;

src/BizHawk.Emulation.Cores/Computers/Doom/DSDA.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,20 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
4242
foreach (var wadFile in _wadFiles)
4343
{
4444
bool recognized = false;
45-
45+
#pragma warning disable CS0618
46+
var filePath = wadFile.RomPath;
47+
#pragma warning restore CS0618
4648
if (wadFile.RomData is [ (byte) 'I', (byte) 'W', (byte) 'A', (byte) 'D', .. ])
4749
{
4850
// Check not more than one IWAD is provided
4951
if (foundIWAD)
5052
{
5153
throw new ArgumentException(
52-
$"More than one IWAD provided. Trying to load '{wadFile.RomPath}', but IWAD '{_iwadName}' was already provided",
54+
$"More than one IWAD provided. Trying to load '{filePath}', but IWAD '{_iwadName}' was already provided",
5355
paramName: nameof(lp));
5456
}
5557

56-
_iwadName = wadFile.RomPath;
58+
_iwadName = filePath;
5759
_iwadData = wadFile.RomData;
5860
foundIWAD = true;
5961
recognized = true;
@@ -62,7 +64,7 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
6264
{
6365
if (_fakePwads.Contains(GetFullName(wadFile).ToLowerInvariant()))
6466
{
65-
_iwadName = wadFile.RomPath;
67+
_iwadName = filePath;
6668
_iwadData = wadFile.RomData;
6769
foundIWAD = true;
6870
}
@@ -77,7 +79,7 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
7779
if (!recognized)
7880
{
7981
throw new ArgumentException(
80-
$"Unrecognized WAD provided: '{wadFile.RomPath}' has non-standard header.",
82+
$"Unrecognized WAD provided: '{filePath}' has non-standard header.",
8183
paramName: nameof(lp));
8284
}
8385
}
@@ -206,11 +208,14 @@ public DSDA(CoreLoadParameters<DoomSettings, DoomSyncSettings> lp)
206208
// Adding PWAD file(s)
207209
foreach (var wadFile in _pwadFiles)
208210
{
209-
_gameMode = _core.dsda_add_wad_file(wadFile.RomPath, wadFile.RomData.Length, _loadCallback);
211+
#pragma warning disable CS0618
212+
var filePath = wadFile.RomPath;
213+
#pragma warning restore CS0618
214+
_gameMode = _core.dsda_add_wad_file(filePath, wadFile.RomData.Length, _loadCallback);
210215
if (_gameMode is LibDSDA.GameMode.Fail)
211216
{
212217
throw new ArgumentException(
213-
$"Could not load PWAD file: '{wadFile.RomPath}'",
218+
$"Could not load PWAD file: '{filePath}'",
214219
paramName: nameof(lp));
215220
}
216221
}
@@ -332,7 +337,10 @@ private void ConditionalArg(bool condition, string setting)
332337
}
333338
}
334339

335-
private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|'));
340+
private string GetFullName(IRomAsset rom)
341+
#pragma warning disable CS0618
342+
=> Path.GetFileName(rom.RomPath.SubstringAfter('|'));
343+
#pragma warning restore CS0618
336344

337345
private static bool PlayerPresent(DoomSyncSettings syncSettings, int port) =>
338346
port switch
@@ -435,7 +443,9 @@ private int LoadCallback(string filename, IntPtr buffer, int maxsize)
435443

436444
foreach (var wadFile in _wadFiles)
437445
{
446+
#pragma warning disable CS0618
438447
if (filename == wadFile.RomPath)
448+
#pragma warning restore CS0618
439449
{
440450
if (wadFile.FileData == null)
441451
{

src/BizHawk.Emulation.Cores/Consoles/Nintendo/3DS/Encore.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ private static void ResetEncoreResolver()
6060
[CoreConstructor(VSystemID.Raw.N3DS)]
6161
public Encore(CoreLoadParameters<EncoreSettings, EncoreSyncSettings> lp)
6262
{
63+
#pragma warning disable CS0618
6364
if (lp.Roms.Exists(static r => HawkFile.PathContainsPipe(r.RomPath)))
65+
#pragma warning restore CS0618
6466
{
6567
throw new InvalidOperationException("3DS does not support compressed ROMs");
6668
}
@@ -134,7 +136,9 @@ public Encore(CoreLoadParameters<EncoreSettings, EncoreSyncSettings> lp)
134136

135137
_serviceProvider.Register<IVideoProvider>(_encoreVideoProvider);
136138

139+
#pragma warning disable CS0618
137140
var romPath = lp.Roms[0].RomPath;
141+
#pragma warning restore CS0618
138142
if (".cia".EqualsIgnoreCase(lp.Roms[0].Extension))
139143
{
140144
var message = new byte[1024];
@@ -177,7 +181,9 @@ public Encore(CoreLoadParameters<EncoreSettings, EncoreSyncSettings> lp)
177181
throw new ArgumentException(paramName: nameof(lp), message: "ROMs after the first ROM should be CIAs");
178182
}
179183

184+
#pragma warning disable CS0618
180185
_core.Encore_InstallCIA(_context, lp.Roms[i].RomPath, dummyBuffer, dummyBuffer.Length);
186+
#pragma warning restore CS0618
181187
}
182188

183189
var errorMessage = new byte[1024];

src/BizHawk.Emulation.Cores/Consoles/Nintendo/BSNES/BsnesCore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public BsnesCore(CoreLoadParameters<SnesSettings, SnesSyncSettings> loadParamete
2525
var ser = new BasicServiceProvider(this);
2626
ServiceProvider = ser;
2727

28+
#pragma warning disable CS0618
2829
this._romPath = Path.ChangeExtension(loadParameters.Roms[0].RomPath.SubstringBefore('|'), null);
30+
#pragma warning restore CS0618
2931
CoreComm = loadParameters.Comm;
3032
_syncSettings = loadParameters.SyncSettings ?? new SnesSyncSettings();
3133
SystemId = loadParameters.Game.System;

src/BizHawk.Emulation.Cores/Consoles/Nintendo/SNES9X/Snes9x.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ public Snes9x(CoreLoadParameters<Settings, SyncSettings> loadParameters)
3030
SystemId = VSystemID.Raw.SNES,
3131
})
3232
{
33+
#pragma warning disable CS0618
3334
this._romPath = Path.ChangeExtension(loadParameters.Roms[0].RomPath.SubstringBefore('|'), null);
35+
#pragma warning restore CS0618
3436
this._currentMsuTrack = new ProxiedFile();
3537

3638
LibSnes9x.OpenAudio openAudioCb = MsuOpenAudio;

src/BizHawk.Emulation.Cores/CoreLoadParameters.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public interface IRomAsset
1212

1313
string Extension { get; }
1414

15+
[Obsolete("you should never have to use this property, Game.Name and Extension should be sufficient")] // not deprecated, do not remove
1516
string RomPath { get; }
1617

1718
/// <summary>

src/BizHawk.Emulation.Cores/Waterbox/NymaCore.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ protected T DoInit<T>(
5757
{
5858
return DoInit<T>(
5959
lp.Roms.Select(r => (r.RomData,
60+
#pragma warning disable CS0618
6061
Path.GetFileName(r.RomPath.SubstringAfter('|')).ToLowerInvariant())).ToArray(),
62+
#pragma warning restore CS0618
6163
lp.Discs.Select(d => d.DiscData).ToArray(),
6264
wbxFilename,
6365
lp.Roms.FirstOrDefault()?.Extension,

0 commit comments

Comments
 (0)