use string.F() extension method everywhere possible; fix various small issues in error messages

This commit is contained in:
Chris Forbes
2011-12-13 23:57:23 +13:00
parent af3d00836a
commit 40029c6688
10 changed files with 28 additions and 28 deletions

View File

@@ -45,7 +45,7 @@ namespace OpenRA.FileFormats
static void ReplicatePrevious( byte[] dest, int destIndex, int srcIndex, int count )
{
if( srcIndex > destIndex )
throw new NotImplementedException( string.Format( "srcIndex > destIndex {0} {1}", srcIndex, destIndex ) );
throw new NotImplementedException("srcIndex > destIndex {0} {1}".F(srcIndex, destIndex));
if( destIndex - srcIndex == 1 )
{
@@ -105,7 +105,7 @@ namespace OpenRA.FileFormats
int count = ctx.ReadWord();
int srcIndex = ctx.ReadWord();
if( srcIndex >= destIndex )
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
throw new NotImplementedException("srcIndex >= destIndex {0} {1}".F(srcIndex, destIndex));
for( int end = destIndex + count ; destIndex < end ; destIndex++ )
dest[ destIndex ] = dest[ srcIndex++ ];
@@ -116,7 +116,7 @@ namespace OpenRA.FileFormats
int count = count3 + 3;
int srcIndex = ctx.ReadWord();
if( srcIndex >= destIndex )
throw new NotImplementedException( string.Format( "srcIndex >= destIndex {0} {1}", srcIndex, destIndex ) );
throw new NotImplementedException("srcIndex >= destIndex {0} {1}".F(srcIndex, destIndex));
for( int end = destIndex + count ; destIndex < end ; destIndex++ )
dest[ destIndex ] = dest[ srcIndex++ ];

View File

@@ -148,7 +148,7 @@ namespace OpenRA.FileFormats
return folder.GetContent(filename + ext);
}
throw new FileNotFoundException( string.Format( "File not found: {0}", filename ), filename );
throw new FileNotFoundException("File not found: {0}".F(filename), filename);
}
public static bool Exists(string filename) { return mountedFolders.Any(f => f.Exists(filename)); }

View File

@@ -97,7 +97,7 @@ namespace OpenRA.FileFormats
else if( h.Format == Format.Format40 )
{
if( !offsets.TryGetValue( h.RefOffset, out h.RefImage ) )
throw new InvalidDataException( string.Format( "Reference doesnt point to image data {0}->{1}", h.Offset, h.RefOffset ) );
throw new InvalidDataException( "Reference doesnt point to image data {0}->{1}".F(h.Offset, h.RefOffset) );
}
}

View File

@@ -15,6 +15,7 @@ namespace OpenRA.FileFormats
public readonly string Type;
public readonly int2 Location;
public readonly int Depth;
public SmudgeReference( string type, int2 location, int depth )
{
Type = type;
@@ -24,8 +25,7 @@ namespace OpenRA.FileFormats
public override string ToString()
{
return string.Format("{0} {1},{2} {3}", Type, Location.X,Location.Y, Depth);
}
return "{0} {1},{2} {3}".F(Type, Location.X, Location.Y, Depth);
}
}
}

View File

@@ -46,9 +46,9 @@ namespace OpenRA.FileFormats
{
string filename;
if (Names.TryGetValue(Hash, out filename))
return string.Format("{0} - offset 0x{1:x8} - length 0x{2:x8}", filename, Offset, Length);
return "{0} - offset 0x{1:x8} - length 0x{2:x8}".F(filename, Offset, Length);
else
return string.Format("0x{0:x8} - offset 0x{1:x8} - length 0x{2:x8}", Hash, Offset, Length);
return "0x{0:x8} - offset 0x{1:x8} - length 0x{2:x8}".F(Hash, Offset, Length);
}
public static uint HashFilename(string name)

View File

@@ -92,7 +92,7 @@ namespace OpenRA
public static float Dot(float2 a, float2 b) { return a.X * b.X + a.Y * b.Y; }
public float2 Round() { return new float2((float)Math.Round(X), (float)Math.Round(Y)); }
public override string ToString() { return string.Format("({0},{1})", X, Y); }
public override string ToString() { return "({0},{1})".F(X, Y); }
public int2 ToInt2() { return new int2((int)X, (int)Y); }
public static float2 Max(float2 a, float2 b) { return new float2(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); }

View File

@@ -55,7 +55,7 @@ namespace OpenRA
public PointF ToPointF() { return new PointF(X, Y); }
public float2 ToFloat2() { return new float2(X, Y); }
public override string ToString() { return string.Format("{0},{1}", X, Y); }
public override string ToString() { return "{0},{1}".F(X, Y); }
// Change endianness of a uint32
public static uint Swap(uint orig)

View File

@@ -54,11 +54,11 @@ namespace OpenRA.FileFormats
public T Get<T>()
{
if (dataMultiple.ContainsKey(typeof(T)))
throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", typeof( T ) ) );
throw new InvalidOperationException("TypeDictionary contains multiple instance of type `{0}`".F(typeof(T)));
object ret;
if (!dataSingular.TryGetValue(typeof(T), out ret))
throw new InvalidOperationException(string.Format("TypeDictionary does not contain instance of type `{0}`", typeof(T)));
throw new InvalidOperationException("TypeDictionary does not contain instance of type `{0}`".F(typeof(T)));
return (T)ret;
}
@@ -70,7 +70,7 @@ namespace OpenRA.FileFormats
public object GetOrDefault(Type t)
{
if (dataMultiple.ContainsKey(t))
throw new InvalidOperationException( string.Format( "TypeDictionary contains multiple instance of type `{0}`", t ) );
throw new InvalidOperationException("TypeDictionary contains multiple instances of type `{0}`".F(t));
object ret;
if (!dataSingular.TryGetValue(t, out ret))

View File

@@ -57,28 +57,28 @@ namespace OpenRA
public bool Contains<T>( Actor actor )
{
if( actor.Destroyed )
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
throw new InvalidOperationException("Attempted to get trait from destroyed object ({0})".F(actor));
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID ).Count() != 0;
}
public T Get<T>( Actor actor )
{
if( actor.Destroyed )
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
throw new InvalidOperationException("Attempted to get trait from destroyed object ({0})".F(actor));
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).Get( actor.ActorID );
}
public T GetOrDefault<T>( Actor actor )
{
if( actor.Destroyed )
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
throw new InvalidOperationException("Attempted to get trait from destroyed object ({0})".F(actor));
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetOrDefault( actor.ActorID );
}
public IEnumerable<T> WithInterface<T>( Actor actor )
{
if( actor.Destroyed )
throw new InvalidOperationException( "Attempted to get trait from destroyed object ({0})".F( actor.ToString() ) );
throw new InvalidOperationException("Attempted to get trait from destroyed object ({0})".F(actor));
return ( (TraitContainer<T>)InnerGet( typeof( T ) ) ).GetMultiple( actor.ActorID );
}
@@ -121,9 +121,9 @@ namespace OpenRA
++queries;
var index = actors.BinarySearchMany( actor );
if( index >= actors.Count || actors[ index ].ActorID != actor )
throw new InvalidOperationException( string.Format( "TraitDictionary does not contain instance of type `{0}`", typeof( T ) ) );
throw new InvalidOperationException("TraitDictionary does not contain instance of type `{0}`".F(typeof(T)));
else if( index + 1 < actors.Count && actors[ index + 1 ].ActorID == actor )
throw new InvalidOperationException( string.Format( "TraitDictionary contains multiple instance of type `{0}`", typeof( T ) ) );
throw new InvalidOperationException("TraitDictionary contains multiple instance of type `{0}`".F(typeof(T)));
else
return traits[ index ];
}
@@ -135,7 +135,7 @@ namespace OpenRA
if( index >= actors.Count || actors[ index ].ActorID != actor )
return default( T );
else if( index + 1 < actors.Count && actors[ index + 1 ].ActorID == actor )
throw new InvalidOperationException( string.Format( "TraitDictionary contains multiple instance of type `{0}`", typeof( T ) ) );
throw new InvalidOperationException("TraitDictionary contains multiple instance of type `{0}`".F(typeof(T)));
else return traits[ index ];
}

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Renderer.Cg
var err = Tao.Cg.Cg.cgGetErrorString(Tao.Cg.Cg.cgGetError());
var results = Tao.Cg.Cg.cgGetLastListing(dev.cgContext);
throw new InvalidOperationException(
string.Format("Cg compile failed ({0}):\n{1}", err, results));
"Cg compile failed ({0}):\n{1}".F(err, results));
}
technique = Tao.Cg.Cg.cgGetFirstTechnique(effect);