Change throw exceptions to use nameof in parameter

This commit is contained in:
teinarss
2021-02-28 17:35:36 +01:00
committed by abcdefg30
parent 53b781960c
commit ed295ae315
30 changed files with 46 additions and 46 deletions

View File

@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common
timestamp = DateTime.UtcNow;
break;
default:
throw new ArgumentOutOfRangeException("state", state, null);
throw new ArgumentOutOfRangeException(nameof(state), state, null);
}
var richPresence = new RichPresence

View File

@@ -103,7 +103,7 @@ namespace OpenRA.Mods.Common.Traits
public void GiveExperience(int amount, bool silent = false)
{
if (amount < 0)
throw new ArgumentException("Revoking experience is not implemented.", "amount");
throw new ArgumentException("Revoking experience is not implemented.", nameof(amount));
if (MaxLevel == 0)
return;

View File

@@ -113,16 +113,16 @@ namespace OpenRA.Mods.Common.Traits
public ShroudRenderer(World world, ShroudRendererInfo info)
{
if (info.ShroudVariants.Length != info.FogVariants.Length)
throw new ArgumentException("ShroudRenderer must define the same number of shroud and fog variants!", "info");
throw new ArgumentException("ShroudRenderer must define the same number of shroud and fog variants!", nameof(info));
if ((info.OverrideFullFog == null) ^ (info.OverrideFullShroud == null))
throw new ArgumentException("ShroudRenderer cannot define overrides for only one of shroud or fog!", "info");
throw new ArgumentException("ShroudRenderer cannot define overrides for only one of shroud or fog!", nameof(info));
if (info.ShroudVariants.Length > byte.MaxValue)
throw new ArgumentException("ShroudRenderer cannot define this many shroud and fog variants.", "info");
throw new ArgumentException("ShroudRenderer cannot define this many shroud and fog variants.", nameof(info));
if (info.Index.Length >= byte.MaxValue)
throw new ArgumentException("ShroudRenderer cannot define this many indexes for shroud directions.", "info");
throw new ArgumentException("ShroudRenderer cannot define this many indexes for shroud directions.", nameof(info));
this.info = info;
this.world = world;

View File

@@ -279,7 +279,7 @@ namespace OpenRA.Mods.Common
case InaccuracyType.Absolute:
return inaccuracy;
default:
throw new InvalidEnumArgumentException("inaccuracyType", (int)inaccuracyType, typeof(InaccuracyType));
throw new InvalidEnumArgumentException(nameof(inaccuracyType), (int)inaccuracyType, typeof(InaccuracyType));
}
}
}

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
string mapPath = null)
{
if (manifestPropertySelector == null)
throw new ArgumentNullException("manifestPropertySelector", "Must pass a non-null manifestPropertySelector");
throw new ArgumentNullException(nameof(manifestPropertySelector), "Must pass a non-null manifestPropertySelector");
Map map = null;
if (mapPath != null)