Fix RCS1218

This commit is contained in:
RoosterDragon
2023-08-11 19:43:15 +01:00
committed by Gustas
parent d2ecd0c777
commit e3646595ab
3 changed files with 6 additions and 11 deletions

View File

@@ -1097,6 +1097,9 @@ dotnet_diagnostic.RCS1215.severity = warning
# Unnecessary unsafe context.
dotnet_diagnostic.RCS1216.severity = warning
# Simplify code branching.
dotnet_diagnostic.RCS1218.severity = warning
# Use pattern matching instead of combination of 'is' operator and cast operator.
dotnet_diagnostic.RCS1220.severity = warning

View File

@@ -105,13 +105,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
defaultSaveFilename = world.Map.Title;
var filenameAttempt = 0;
while (true)
{
if (!File.Exists(Path.Combine(baseSavePath, defaultSaveFilename + ".orasav")))
break;
while (File.Exists(Path.Combine(baseSavePath, defaultSaveFilename + ".orasav")))
defaultSaveFilename = world.Map.Title + $" ({++filenameAttempt})";
}
var saveButton = panel.Get<ButtonWidget>("SAVE_BUTTON");
saveButton.IsDisabled = () => string.IsNullOrWhiteSpace(saveTextField.Text);

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Platforms.Default
var buffer = new List<byte>();
var offset = 0;
while (true)
do
{
var b = Marshal.ReadByte(devicesPtr, offset++);
if (b != 0)
@@ -85,11 +85,8 @@ namespace OpenRA.Platforms.Default
// A null indicates termination of that string, so add that to our list.
devices.Add(Encoding.UTF8.GetString(buffer.ToArray()));
buffer.Clear();
// Two successive nulls indicates the end of the list.
if (Marshal.ReadByte(devicesPtr, offset) == 0)
break;
}
while (Marshal.ReadByte(devicesPtr, offset) != 0); // Two successive nulls indicates the end of the list.
return devices.ToArray();
}